mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: auth logout page (#27831)
* feat: auth logout page * feat: skip login if already logged in
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user