Exemplo n.º 1
0
        public async Task <User> AuthenticateAsync(AuthCommand command)
        {
            var user = await _userRepository.GetByNameOrEmailAsync(command.Login);

            if (user == null)
            {
                throw new AuthenticationException("Login not found");
            }

            if (!PasswordHelper.CompareWithHash(command.Password, user.Password))
            {
                throw new AuthenticationException("Password is incorrect");
            }

            return(user);
        }