コード例 #1
0
        public async Task <IActionResult> Login([FromBody] UserLoginReqObj request)
        {
            var authResponse = await _identityServer.LoginAsync(request.UserName, request.Password);

            if (authResponse.Token == null)
            {
                return(BadRequest(new AuthFailedResponse
                {
                    Status = new APIResponseStatus
                    {
                        IsSuccessful = authResponse.Status.IsSuccessful,
                        Message = new APIResponseMessage
                        {
                            FriendlyMessage = authResponse?.Status?.Message?.FriendlyMessage,
                            TechnicalMessage = authResponse?.Status?.Message?.TechnicalMessage
                        }
                    }
                }));
            }

            return(Ok(new AuthSuccessResponse
            {
                Token = authResponse.Token,
                RefreshToken = authResponse.RefreshToken
            }));
        }