diff options
| author | Fuwn <[email protected]> | 2024-01-26 13:04:20 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-26 13:04:20 -0800 |
| commit | 9188ef0dec7f5cdb46427014be8410c1f6c7b81e (patch) | |
| tree | 0cfb3b406e3bb49c4298136fee31146614c5753e /src/routes | |
| parent | fix(html): more robust (ultimate) height limiter (diff) | |
| download | due.moe-9188ef0dec7f5cdb46427014be8410c1f6c7b81e.tar.xz due.moe-9188ef0dec7f5cdb46427014be8410c1f6c7b81e.zip | |
fix: authentication loop for identity
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/+layout.svelte | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a9c294c2..a1e9ef4b 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -45,6 +45,13 @@ ? 200 : -200; + $: { + if (data.user !== undefined) + getUserIdentity(data.user).then((h) => { + if ($userIdentity.id === -2) userIdentity.set(h); + }); + } + onMount(async () => { if (browser && localStorage.getItem('redirect')) { window.location.href = localStorage.getItem('redirect') ?? '/'; @@ -53,10 +60,6 @@ } settings.get(); - - if (data.user !== undefined) { - if ($userIdentity.id === -1) userIdentity.set(await getUserIdentity(data.user)); - } }); </script> @@ -98,7 +101,19 @@ {$locale().navigation.logIn} </a> {:else} - <a href={root('/api/authentication/log-out')} class="header-item"> + <a + href={'#'} + class="header-item" + on:click={() => { + userIdentity.set({ + id: -2, + name: '', + avatar: 'https://s4.anilist.co/file/anilistcdn/user/avatar/large/default.png' + }); + + window.location.href = root('/api/authentication/log-out'); + }} + > {$locale().navigation.logOut} </a> {#if data.user} |