コード例 #1
0
        public IActionResult Authenticate(AuthenticateRequest request)
        {
            var response = _services.Authenticate(request);

            if (response == null)
            {
                return(new NotFoundObjectResult(new { message = $"User: {request.Username} Not Found" }));
            }

            if (response.Token == null)
            {
                return(new UnauthorizedObjectResult(new { message = $"Cannot authenticate user: {request.Username}" }));
            }

            return(new OkObjectResult(response));
        }