public void AddNewAccount_Success() { BCryptHashGenerator hashGenerator = new BCryptHashGenerator(); string salt = hashGenerator.GenerateSalt(); string encryptedPassword = hashGenerator.GenerateEncryptedString("adahplf0015", salt); Account account = new Account() { EmailAddress = "*****@*****.**", Username = "******", Password = encryptedPassword, Salt = salt, EmailWasVerified = true, ActivationToken = "3df4h", RecoveryToken = "df567" }; Player player = new Player() { EmailAddress = "*****@*****.**", Score = 0 }; UnitOfWork unitOfWork = new UnitOfWork(new MemoryGameContext()); unitOfWork.Players.Add(player); unitOfWork.Complete(); unitOfWork.Accounts.Add(account); int expected = 1; int actual = unitOfWork.Complete(); Assert.AreEqual(expected, actual); }
private void HashAccountPassword() { BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator(); string salt = bCryptHashGenerator.GenerateSalt(); string hashedPassword = bCryptHashGenerator.GenerateHashedString(Coordinator.User.Account.Password, salt); Coordinator.User.Account.Password = hashedPassword; }
private bool LoginIsValid() { BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator(); string salt = GetPasswordSalt(); string encryptedPassword = bCryptHashGenerator.GenerateEncryptedString(_password, salt); bool hasAccessRights = _accessibilityServiceClient.HasAccessRights(_username, encryptedPassword); return(hasAccessRights); }
private void HashAccountPassword() { BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator(); string salt = bCryptHashGenerator.GenerateSalt(); string hashedPassword = bCryptHashGenerator.GenerateHashedString(Practicioner.User.Account.Password, salt); Practicioner.User.Account.Password = hashedPassword; Practicioner.User.Account.Salt = salt; }
private void HashAccountPassword() { BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator(); string salt = bCryptHashGenerator.GenerateSalt(); account.Salt = salt; string hashedPassword = bCryptHashGenerator.GenerateHashedString(account.Password, salt); account.Password = hashedPassword; }
private bool IsValidAccountPassword() { BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator(); string hashedPassword = bCryptHashGenerator.GenerateHashedString(accountCurrent.Password, accountReceived.Salt); accountCurrent.Password = hashedPassword; _password = hashedPassword; AccountValidator accountValidator = new AccountValidator(accountReceived); ValidationResult dataValidationResult = accountValidator.Validate(accountCurrent); IList <ValidationFailure> validationFailures = dataValidationResult.Errors; UserFeedback userFeedback = new UserFeedback(FormGrid, validationFailures); userFeedback.ShowFeedback(); return(dataValidationResult.IsValid); }
public void SaveAccount() { try { var accountCurrent = _unitOfWork.Accounts.Get(1); BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator(); string salt = bCryptHashGenerator.GenerateSalt(); string hashedPassword = bCryptHashGenerator.GenerateHashedString("MMOL78945", salt); accountCurrent.Password = hashedPassword; accountCurrent.Salt = salt; } catch (System.NullReferenceException) { } int expected = 1; int actual = _data.Count; Assert.AreEqual(expected, actual); }
private bool PlayerWasSuccessfullyRegistered() { BCryptHashGenerator hashGenerator = new BCryptHashGenerator(); string salt = hashGenerator.GenerateSalt(); string encryptedPassword = hashGenerator.GenerateEncryptedString(_password, salt); MemoryGameService.PlayerRegistryServiceClient playerRegistryServiceClient = new MemoryGameService.PlayerRegistryServiceClient(); PlayerDto playerDTO = new PlayerDto() { Username = _username, EmailAddress = _emailAddress, Password = encryptedPassword, VerificationToken = _verificationToken }; bool playerWasSuccessfullyRegistered = playerRegistryServiceClient.RegisterNewPlayer(playerDTO, salt); return(playerWasSuccessfullyRegistered); }
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); }