private User CreateUser(RegistrationRequest registrationRequest, HashedPasswordData hashedPassword) { User user = Mapper.Map <User>(registrationRequest); user.HashedPassword = hashedPassword.HashedPassword; user.PasswordSalt = hashedPassword.PasswordSalt; _userModifier.CreateUser(user); return(user); }
public static HashedPasswordData CreateHashedPassword(string password) { HashedPasswordData hashedPasswordData = new HashedPasswordData(); using (var hmac = new System.Security.Cryptography.HMACSHA512()) { hashedPasswordData.PasswordSalt = hmac.Key; hashedPasswordData.HashedPassword = hmac.ComputeHash(Encoding.UTF8.GetBytes(password)); } return(hashedPasswordData); }
public UserDto RegisterNewUser(RegistrationRequest registrationRequest, out RegistrationStatus registrationStatus) { registrationStatus = ValidateRegistration(registrationRequest); if (registrationStatus != RegistrationStatus.SUCCESS) { return(null); } HashedPasswordData hashedPassword = PasswordHashComputer.CreateHashedPassword(registrationRequest.Password); User user = CreateUser(registrationRequest, hashedPassword); return(Mapper.Map <UserDto>(user)); }