From 502495883d8a0cd5af176940b409adf245a00d47 Mon Sep 17 00:00:00 2001 From: martin <74269598+martabal@users.noreply.github.com> Date: Fri, 15 Dec 2023 03:29:05 +0100 Subject: [PATCH] fix(web): log out (#5706) * fix: logging out * fix: websocket --------- Co-authored-by: Alex Tran --- .../shared-components/navigation-bar/navigation-bar.svelte | 3 ++- web/src/lib/stores/user.store.ts | 6 +++++- web/src/lib/stores/websocket.ts | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelte b/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelte index c6fa67cf18..f92f8f0f95 100644 --- a/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelte +++ b/web/src/lib/components/shared-components/navigation-bar/navigation-bar.svelte @@ -16,7 +16,7 @@ import UserAvatar from '../user-avatar.svelte'; import { featureFlags } from '$lib/stores/server-config.store'; import { mdiMagnify, mdiTrayArrowUp, mdiCog } from '@mdi/js'; - import { user } from '$lib/stores/user.store'; + import { resetSavedUser, user } from '$lib/stores/user.store'; export let showUploadButton = true; @@ -28,6 +28,7 @@ }>(); const logOut = async () => { + resetSavedUser(); const { data } = await api.authenticationApi.logout(); goto(data.redirectUri || '/auth/login?autoLaunch=0'); }; diff --git a/web/src/lib/stores/user.store.ts b/web/src/lib/stores/user.store.ts index 0b886746e2..8659506cc5 100644 --- a/web/src/lib/stores/user.store.ts +++ b/web/src/lib/stores/user.store.ts @@ -1,7 +1,7 @@ import { get, writable } from 'svelte/store'; import type { UserResponseDto } from '@api'; -export const user = writable(); +export let user = writable(); export const setUser = (value: UserResponseDto) => { user.set(value); @@ -10,3 +10,7 @@ export const setUser = (value: UserResponseDto) => { export const getSavedUser = () => { return get(user); }; + +export const resetSavedUser = () => { + user = writable(); +}; diff --git a/web/src/lib/stores/websocket.ts b/web/src/lib/stores/websocket.ts index 5871771e8d..3bfa199cfd 100644 --- a/web/src/lib/stores/websocket.ts +++ b/web/src/lib/stores/websocket.ts @@ -2,7 +2,6 @@ import type { AssetResponseDto, ServerVersionResponseDto } from '@api'; import { Socket, io } from 'socket.io-client'; import { writable } from 'svelte/store'; import { loadConfig } from './server-config.store'; -import { getSavedUser } from './user.store'; export interface ReleaseEvent { isAvailable: boolean; @@ -26,7 +25,7 @@ let websocket: Socket | null = null; export const openWebsocketConnection = () => { try { - if (websocket || !getSavedUser()) { + if (websocket) { return; }