public PasswordVerificationResult VerifyHashedPassword(User user, string hashedPassword, string providedPassword) { bool isValid = passwordHelper.IsValid(providedPassword, hashedPassword); return(isValid ? PasswordVerificationResult.Success : PasswordVerificationResult.Failed); }
public async Task <Maybe <User> > GetByLoginCredentials(LoginCredentials credentials) { using (var ctx = GetContext()) { var user = await ctx.Users.AsQueryable() .Where(x => x.Username == credentials.Username) .SingleOrDefaultAsync(); return(user != null && passwordHelper.IsValid(credentials.Password, user.PasswordHash) ? new Maybe <User> (user.ToDto()) : Maybe <User> .Fail); } }