public virtual LoginResponse Execute(LoginRequest request) { var user = _emailQueryObject.Execute(request.EmailAddress); if (user == null) { return new LoginResponse { ResponseMessage = "User Not Logged In" } } ; BCryptPasswordHash pwHash = new BCryptPasswordHash(); var result = pwHash.VerifyPassword(request.Password, user.PasswordHash); if (result) { return new LoginResponse { ResponseMessage = "User Logged In" } } ; //TODO:Log login failures //TODO:Log login success //TODO:Generate and return JWT return(new LoginResponse { ResponseMessage = "User Not Logged In" }); } }
public void CanHashAndVerifyPassword() { var passwordHashUtility = new BCryptPasswordHash(); var hashed = passwordHashUtility.HashPassword("password"); Assert.True(passwordHashUtility.VerifyPassword("password", hashed)); }