Beispiel #1
0
        /// <inheritdoc/>
        public bool SetNewPassword(PasswordModificationCredentialsDto passwordModificationCredentials)
        {
            UnitOfWork unitOfWork   = new UnitOfWork(new MemoryGameContext());
            string     emailAddress = passwordModificationCredentials.EmailAddress;
            string     salt         = passwordModificationCredentials.Salt;
            string     newPassword  = passwordModificationCredentials.NewPassword;

            try
            {
                Account account = unitOfWork.Accounts.Get(emailAddress);
                account.Password = newPassword;
                account.Salt     = salt;
                int rowsModified = unitOfWork.Complete();
                return(rowsModified == 1);
            }
            catch (SqlException sqlException)
            {
                _logger.Fatal("AccountModifiability.cs: An exception was thrown while trying to get an Account entity with " +
                              "the specified primary key (emailAddress) " +
                              "from the database. Method SetNewPassword, line 89", sqlException);
                throw;
            }
            catch (EntityException entityException)
            {
                _logger.Fatal("AccountModifiability.cs: An exception was thrown while trying to access the database. " +
                              "It is possible that the database is corrupted or that it does not exist. " +
                              "Method SetNewPassword, line 86", entityException);
                throw;
            }
            finally
            {
                unitOfWork.Dispose();
            }
        }
Beispiel #2
0
        private bool SetNewPassword()
        {
            IEncryption bCryptHashGenerator = new BCryptHashGenerator();
            string      newPassword         = NewPasswordBox.Password;

            if (newPassword == "")
            {
                return(false);
            }
            string salt = bCryptHashGenerator.GenerateSalt();
            string encryptedNewPassword = bCryptHashGenerator.GenerateEncryptedString(newPassword, salt);
            AccountModifiabilityServiceClient  accountModifiabilityServiceClient = new AccountModifiabilityServiceClient();
            PasswordModificationCredentialsDto passwordModificationCredentials   = new PasswordModificationCredentialsDto()
            {
                EmailAddress = _emailAddress,
                Salt         = salt,
                NewPassword  = encryptedNewPassword
            };
            bool newPasswordWasAssigned = accountModifiabilityServiceClient.SetNewPassword(passwordModificationCredentials);

            return(newPasswordWasAssigned);
        }