Seperated logout function

This commit is contained in:
WardPearce
2026-02-16 20:48:22 +13:00
parent 8a19040294
commit cfdc32ed8b
4 changed files with 25 additions and 16 deletions
@@ -11,7 +11,12 @@
import type { RgbaColor, HsvaColor, Colord } from 'colord';
import { _ } from '$lib/i18n';
import { get } from 'svelte/store';
import { isUnrestrictedPlatform, setInvidiousInstance, goToInvidiousLogin } from '../../misc';
import {
isUnrestrictedPlatform,
setInvidiousInstance,
goToInvidiousLogin,
invidiousLogout
} from '../../misc';
import { getPages, type Pages } from '../../navPages';
import ColorPicker from 'svelte-awesome-color-picker';
import {
@@ -158,12 +163,7 @@
<span>{$_('linkInvidious')}</span>
</button>
{:else}
<button
onclick={() => {
invidiousAuthStore.set(null);
goto(resolve('/', {}));
}}
>
<button onclick={invidiousLogout}>
<i>link_off</i>
<span>{$_('unlinkInvidious')}</span>
</button>
@@ -1,6 +1,6 @@
<script lang="ts">
import { _ } from '$lib/i18n';
import { logout } from '$lib/misc';
import { materialiousLogout } from '$lib/misc';
let clickCount = $state(0);
const clicksToDelte = 3;
@@ -16,7 +16,7 @@
if (clicksToDelte - clickCount === 0) {
await fetch('/api/user/delete', { method: 'DELETE' });
logout();
materialiousLogout();
}
}
</script>
+6 -3
View File
@@ -312,7 +312,12 @@ export async function goToInvidiousLogin() {
}
}
export async function logout() {
export async function invidiousLogout() {
invidiousAuthStore.set(null);
goto(resolve('/', {}));
}
export async function materialiousLogout() {
if (isYTBackend()) {
await clearFeedYTjs();
}
@@ -320,8 +325,6 @@ export async function logout() {
if (isOwnBackend()?.internalAuth) {
fetch('/api/user/logout', { method: 'DELETE' });
rawMasterKeyStore.set(undefined);
} else {
invidiousAuthStore.set(null);
}
goto(resolve('/', {}));
+10 -4
View File
@@ -32,7 +32,13 @@
import 'material-dynamic-colors';
import { onMount } from 'svelte';
import { _ } from '$lib/i18n';
import { goToInvidiousLogin, isYTBackend, logout, truncate } from '$lib/misc';
import {
goToInvidiousLogin,
invidiousLogout,
isYTBackend,
materialiousLogout,
truncate
} from '$lib/misc';
import Author from '$lib/components/Author.svelte';
import Toast from '$lib/components/Toast.svelte';
import { isOwnBackend } from '$lib/shared';
@@ -141,15 +147,15 @@
onMount(async () => {
if ($invidiousAuthStore && !isYTBackend()) {
loadNotifications().catch(() => logout());
loadNotifications().catch(() => invidiousLogout());
}
if ($rawMasterKeyStore) {
fetch('/api/user/isLoggedIn', { method: 'GET', credentials: 'same-origin' })
.then((resp) => {
if (!resp.ok) logout();
if (!resp.ok) materialiousLogout();
})
.catch(logout);
.catch(materialiousLogout);
}
resetScroll();