Refactored logout process
This commit is contained in:
@@ -102,16 +102,15 @@ public static class Api
|
||||
});
|
||||
});
|
||||
|
||||
app.MapGet("/logout", async (HttpContext context, IHttpClientFactory httpClientFactory, IOptions<LiteCharmsSettings> settings) =>
|
||||
app.MapGet("/logout", async (HttpContext context) =>
|
||||
{
|
||||
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
var schemesToSignOut = new[] { CookieAuthenticationDefaults.AuthenticationScheme, OpenIdConnectDefaults.AuthenticationScheme, };
|
||||
|
||||
string currentBaseUrl = $"https://{context.Request.Host}{context.Request.PathBase}/";
|
||||
string postLogoutRedirectDestination = "/";
|
||||
|
||||
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
|
||||
{
|
||||
RedirectUri = currentBaseUrl,
|
||||
});
|
||||
await context.SignOutAsync(scheme: null, properties: new AuthenticationProperties { RedirectUri = postLogoutRedirectDestination, });
|
||||
|
||||
foreach (var scheme in schemesToSignOut) await context.SignOutAsync(scheme);
|
||||
});
|
||||
|
||||
return app;
|
||||
|
||||
Reference in New Issue
Block a user