feat: auth logout page (#27831)

* feat: auth logout page

* feat: skip login if already logged in
This commit is contained in:
Jason Rasmussen
2026-04-15 16:33:52 -04:00
committed by GitHub
parent ac06514db5
commit 4ffa26c969
10 changed files with 48 additions and 26 deletions
+14 -12
View File
@@ -41,6 +41,12 @@ class AuthManager {
return this.#preferences;
}
constructor() {
eventManager.on({
SessionDelete: () => goto(Route.logout()),
});
}
async load() {
if (authManager.authenticated) {
return;
@@ -84,30 +90,26 @@ class AuthManager {
}
async logout() {
let redirectUri;
let redirectUri = Route.login();
try {
const response = await logout();
if (response.redirectUri) {
redirectUri = response.redirectUri;
}
} catch (error) {
console.log('Error logging out:', error);
} catch {
// noop
}
redirectUri = redirectUri ?? Route.login();
try {
if (redirectUri.startsWith('/')) {
await goto(redirectUri);
} else {
globalThis.location.href = redirectUri;
}
} finally {
if (redirectUri.startsWith('/')) {
this.isPurchased = false;
this.reset();
eventManager.emit('AuthLogout');
await goto(redirectUri);
} else {
globalThis.location.href = redirectUri;
}
}
@@ -74,6 +74,7 @@ export type Events = {
UserAdminDeleted: [{ id: string }];
SessionLocked: [];
SessionDelete: [];
SystemConfigUpdate: [SystemConfigDto];