This commit is contained in:
Krzysztof Famulski 2024-11-03 17:53:59 +01:00
parent a5dd73d8f0
commit 0e7c5edef3
2 changed files with 12 additions and 0 deletions

View File

@ -36,6 +36,12 @@
// Dodaj token do nagłówka Authorization // Dodaj token do nagłówka Authorization
context.Request.Headers["Authorization"] = $"Bearer {token}"; context.Request.Headers["Authorization"] = $"Bearer {token}";
} else
{
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
context.Session.Remove("AccessToken");
context.Session.Remove("RefreshToken");
context.Session.Remove("TokenExpiration");
} }
await _next(context); await _next(context);

View File

@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
@ -80,4 +81,9 @@ app.MapControllerRoute(
name: "default", name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"); pattern: "{controller=Home}/{action=Index}/{id?}");
//app.Use(async (context, next) =>
//{
//// await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
// await next();
//});
app.Run(); app.Run();