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);
|
||||
|
||||
@@ -9,6 +9,11 @@ using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddConsole();
|
||||
builder.Logging.AddDebug();
|
||||
|
||||
|
||||
// Specify the paths to your certificate and key files
|
||||
var certPath = Path.Combine(Directory.GetCurrentDirectory(), "cert.pem");
|
||||
var keyPath = Path.Combine(Directory.GetCurrentDirectory(), "key.pem");
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e57b47cae362bcdd292021d92f19844516cd42b7")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8e4322649e4df45cec652c7098c929f725ff16bf")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("API")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
9dc91fd589f405d9b89d7ec2470007cfa5e9ff60c37dde9d153100048a5640aa
|
||||
453ffda4295c5e0dce92614f7a406e66ffae57500f6c15603961c11cf348a009
|
||||
|
||||
Reference in New Issue
Block a user