示例#1
0
        public IActionResult Post(
            [FromBody] Credencial credenciais,
            [FromServices] ILoginService loginService)
        {
            try
            {
                var validarUsuario = loginService.Autentica(credenciais);

                if (validarUsuario == null)
                {
                    return(NoContent());
                }

                var correlationId = Guid.NewGuid();
                _logger.LogInformation($"{correlationId} Usuario logado:  {JsonSerializer.Serialize(validarUsuario)}");

                return(Ok(new
                {
                    token = JwtToken.GenerateToken(validarUsuario, _config),
                    usuario = validarUsuario,
                    correlationId = correlationId
                }));;
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }