0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-07 00:50:23 -05:00

fix(web): log out (#5706)

* fix: logging out

* fix: websocket

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
martin 2023-12-15 03:29:05 +01:00 committed by GitHub
parent 2836b8cda9
commit 502495883d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View file

@ -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');
};

View file

@ -1,7 +1,7 @@
import { get, writable } from 'svelte/store';
import type { UserResponseDto } from '@api';
export const user = writable<UserResponseDto>();
export let user = writable<UserResponseDto>();
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<UserResponseDto>();
};

View file

@ -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;
}