public async Task <UserViewModel> CreateAsync(SignupViewModel model, CancellationToken ct) { var existingUser = await _userRepository.GetByEmailAsync(model.Email, ct : ct); if (existingUser is not null) { return(null); } var user = model.Adapt <User>(); var secret = PasswordSecret.Create(model.Password); user.Name ??= user.Email; user.PasswordHash = secret.Hash; user.Salt = secret.Salt; var createdUser = await _userRepository.CreateAsync(user, ct); return(createdUser.Adapt <UserViewModel>()); }
internal static bool VerifyPassword(string password, PasswordSecret passwordSecret) { return(BCrypt.Net.BCrypt.Verify(password + passwordSecret.Salt, passwordSecret.Hash)); }