public IActionResult Authenticate([FromBody] UserLoginViewModel viewModel)
        {
            string error;
            var    token = _authenticationAppService.Authenticate(viewModel, out error);

            if (!string.IsNullOrWhiteSpace(error))
            {
                return(NotFound(new { message = error }));
            }

            return(GetResponse(new { token = token }));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage Authenticate(Credential credential)
        {
            var request = new AuthenticationRequest()
            {
                Credential = credential
            };

            var authResponse = _authenticationAppService.Authenticate(request);

            var response = Request.BuildResponse(HttpStatusCode.OK, authResponse);

            response.SetCookie(authResponse.TokenName,
                               authResponse.AuthToken,
                               authResponse.Expires);

            return(response);
        }