예제 #1
0
        public IActionResult Post(UsuarioAutenticacaoModel model,
                                  [FromServices] IUsuarioApplicationService usuarioApplicationService,
                                  [FromServices] JwtConfiguration jwtConfiguration)
        {
            try
            {
                var usuario = usuarioApplicationService.GetByLoginAndSenha(model);

                if (usuario != null)
                {
                    return(Ok(jwtConfiguration.GenerateToken(usuario.Login)));
                }
                else
                {
                    return(StatusCode(403, "Usuário não encontrado"));
                }
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }