Exemplo n.º 1
0
        public async Task <LoginResponse> Login([FromBody] LoginRequest request)
        {
            var user = await _userRepository.GetByUserName(request.UserName);

            if (user == null || !_passwordProvider.ValidatePassword(request.Password, user.PasswordHash))
            {
                return(LoginResponse.Unauthorized());
            }

            var token = _tokenProvider.GenerateToken(user.UserName);

            return(LoginResponse.Authorized(token));
        }