Beispiel #1
0
    public async Task <User> GetUserAsync(string userName, string password)
    {
        var result = await _users
                     .Include(x => x.UserRoles)
                     .Include(x => x.UserRefreshTokens)
                     .SingleOrDefaultAsync(x => x.UserName == userName)
                     ?? throw new EntityNotFoundException();

        if (result.PasswordHash != CryptographyUtility.Hash(password.Trim(), result.Salt))
        {
            throw new EntityNotFoundException();
        }

        return(result);
    }