示例#1
0
        public async Task <ActionResult <LoginResponseViewModel> > LoginAsync([FromBody] LoginRequestViewModel request, CancellationToken cancellationToken)
        {
            var response = await _loginGateway.LoginAsync(_mapper.Map <LoginRequest>(request), cancellationToken);

            if (string.IsNullOrWhiteSpace(response?.Token))
            {
                return(Ok(new LoginResponseViewModel("LoginAsync failed", false)));
            }

            Cookies.SetUserToken(Response, response.Token);

            return(Ok(new LoginResponseViewModel($"Welcome {request.Username}", true)));
        }