public async Task <User> VerifyLoginAsync(string email, string password) { var user = await _dataContext.Users.FirstOrDefaultAsync(x => x.Email.Equals(email)); if (user != null && PasswordHashService.ValidatePassword(password, user.Password)) { return(user); } return(null); }
public string ValidateLoginRequest(LoginRequest request, User user) { if (user == null) { return("No user is registered with this email"); } if (user.Password == null) { return("User has only registered with an external provider"); } if (!PasswordHashService.ValidatePassword(request.Password, user.Password)) { return("Incorrect password"); } return(null); }
public async Task <User> RegisterUser(RegisterRequest request) { string hashedPassword = request.Password == null ? null : PasswordHashService.HashPassword(request.Password); var user = new User { Email = request.Email, Username = request.Username, Password = hashedPassword, ExternalId = request.ExternalId, PhoneNumber = request.PhoneNumber, Created = DateTime.Now }; return(await _userRepository.AddUser(user)); }