예제 #1
0
        public async Task <User> LoginAsync(UserLoginResource credentials)
        {
            var user = await _context.Users.FirstOrDefaultAsync(u => u.UserName == credentials.Username.ToLower());

            if (user == null || !_hashHelper.VerifyPasswordHash(credentials.Password, user.PasswordHash, user.PasswordSalt))
            {
                return(null);
            }

            return(user);
        }
예제 #2
0
        public User Authenticate(string email, string password)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                return(null);
            }

            var user = Get(email);

            if (user == null)
            {
                return(null);
            }

            if (!_helper.VerifyPasswordHash(password, user.PasswordHash, user.PasswordSalt))
            {
                return(null);
            }

            return(user);
        }