Exemple #1
0
        public async Task <IActionResult> GenerateToken(
            [FromBody] AuthModel authModel,
            [FromServices] ILoginRepository loginRepository,
            [FromServices] IJwtGenerationCommand jwtGenerationCommand,
            [FromServices] ErrorLoggingRepository errorLoggingRepository
            )
        {
            try
            {
                var user = await loginRepository.Obter(authModel);

                return(Ok(new { Token = jwtGenerationCommand.GenerateToken(user), Auth = user }));
            }
            catch (Exception ex)
            {
                await errorLoggingRepository.RegistrarErro(ex);

                return(BadRequest(ex));
            }
        }