Ejemplo n.º 1
0
        public async Task <User> GetByLoginAsync(string userName, string password)
        {
            if (string.IsNullOrWhiteSpace(userName) || string.IsNullOrWhiteSpace(password))
            {
                return(null);
            }

            User user = await _userRepo.GetByUserNameAsync(userName);

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

            byte[] passwordHash = _hashEncoder.EncodeToHash(password);

            if (user.PasswordHash.SequenceEqual(passwordHash))
            {
                return(user);
            }
            else
            {
                return(null);
            }
        }