Ejemplo n.º 1
0
        public async Task <IActionResult> Authenticate([FromBody] AuthModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var signInResult = await _authenticationService.AuthenticateAsync(model);

            if (!signInResult.IsAuthenticated)
            {
                return(BadRequest("User name and/or password does not match."));
            }

            SetAuthenticationCookie(signInResult.RefreshToken);
            return(Ok(signInResult.Token));
        }