logger added

This commit is contained in:
andrei-mihnea-cerbu
2024-05-02 14:15:14 +03:00
parent 8e4322649e
commit beedfcf666
10 changed files with 18 additions and 10 deletions
+5 -2
View File
@@ -8,11 +8,13 @@ public class JwtMiddleware
{
private readonly IJwtService _jwtService;
private readonly RequestDelegate _next;
private readonly ILogger<JwtMiddleware> _logger;
public JwtMiddleware(RequestDelegate next, IJwtService jwtService)
public JwtMiddleware(RequestDelegate next, IJwtService jwtService, ILogger<JwtMiddleware> logger)
{
_next = next;
_jwtService = jwtService;
_logger = logger;
}
public async Task Invoke(HttpContext context)
@@ -32,7 +34,8 @@ public class JwtMiddleware
}
else
{
var token = context.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last();
var token = context.Request.Headers.Authorization.FirstOrDefault()?.Split(" ").Last();
_logger.LogInformation(token);
if (token != null && _jwtService.ValidateJwtToken(token))
{
await _next(context);