mirror of
https://github.com/immich-app/immich.git
synced 2025-12-18 09:13:15 +03:00
fix(web,server): web socket auth (for web) (#4632)
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
import { handleError } from '$lib/utils/handle-error';
|
||||
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
|
||||
import { api } from '@api';
|
||||
import { openWebsocketConnection } from '$lib/stores/websocket';
|
||||
import { closeWebsocketConnection, openWebsocketConnection } from '$lib/stores/websocket';
|
||||
|
||||
let showNavigationLoadingBar = false;
|
||||
export let data: LayoutData;
|
||||
@@ -28,7 +28,18 @@
|
||||
api.setKey($page.params.key);
|
||||
}
|
||||
|
||||
beforeNavigate(() => {
|
||||
beforeNavigate(({ from, to }) => {
|
||||
const fromRoute = from?.route?.id || '';
|
||||
const toRoute = to?.route?.id || '';
|
||||
|
||||
if (fromRoute.startsWith('/auth') && !toRoute.startsWith('/auth')) {
|
||||
openWebsocketConnection();
|
||||
}
|
||||
|
||||
if (!fromRoute.startsWith('/auth') && toRoute.startsWith('/auth')) {
|
||||
closeWebsocketConnection();
|
||||
}
|
||||
|
||||
showNavigationLoadingBar = true;
|
||||
});
|
||||
|
||||
@@ -37,7 +48,9 @@
|
||||
});
|
||||
|
||||
onMount(async () => {
|
||||
openWebsocketConnection();
|
||||
if ($page.route.id?.startsWith('/auth') === false) {
|
||||
openWebsocketConnection();
|
||||
}
|
||||
|
||||
try {
|
||||
await loadConfig();
|
||||
|
||||
Reference in New Issue
Block a user