refactor: move managers to new folder (#17929)

This commit is contained in:
Daniel Dietzler
2025-04-28 16:56:04 +02:00
committed by GitHub
parent 1b5fc9c665
commit a17390a422
15 changed files with 16 additions and 16 deletions

View File

@@ -0,0 +1,33 @@
import { goto } from '$app/navigation';
import { AppRoute } from '$lib/constants';
import { eventManager } from '$lib/managers/event-manager.svelte';
import { logout } from '@immich/sdk';
class AuthManager {
async logout() {
let redirectUri;
try {
const response = await logout();
if (response.redirectUri) {
redirectUri = response.redirectUri;
}
} catch (error) {
console.log('Error logging out:', error);
}
redirectUri = redirectUri ?? AppRoute.AUTH_LOGIN;
try {
if (redirectUri.startsWith('/')) {
await goto(redirectUri);
} else {
globalThis.location.href = redirectUri;
}
} finally {
eventManager.emit('auth.logout');
}
}
}
export const authManager = new AuthManager();