logger added
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user