aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-12-24 07:16:33 -0800
committerFuwn <[email protected]>2023-12-24 07:16:33 -0800
commit45e30002f2e0f9d877c9669c0fb34e1e0f9db1e8 (patch)
tree24475d389fc734e6bce089ea1c17b332aec4963b /src
parentfeat(html): umami analytics (diff)
downloaddue.moe-45e30002f2e0f9d877c9669c0fb34e1e0f9db1e8.tar.xz
due.moe-45e30002f2e0f9d877c9669c0fb34e1e0f9db1e8.zip
feat(layout): redirect to login point
Diffstat (limited to 'src')
-rw-r--r--src/routes/+layout.svelte13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 8ec6cb28..2fdfbc4d 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -4,12 +4,19 @@
import { onMount } from 'svelte';
import userIdentity from '../stores/userIdentity';
import settings from '../stores/settings';
+ import { browser } from '$app/environment';
export let data;
let currentUserIdentity = { name: '...', id: -1 };
onMount(async () => {
+ if (browser && localStorage.getItem('redirect')) {
+ window.location.href = localStorage.getItem('redirect') ?? '/';
+
+ localStorage.removeItem('redirect');
+ }
+
settings.get();
if (data.user !== undefined) {
@@ -39,6 +46,12 @@
{#if data.user === undefined}
<a
href={`https://anilist.co/api/v2/oauth/authorize?client_id=${env.PUBLIC_ANILIST_CLIENT_ID}&redirect_uri=${env.PUBLIC_ANILIST_REDIRECT_URI}&response_type=code`}
+ on:click={() => {
+ localStorage.setItem(
+ 'redirect',
+ window.location.origin + window.location.pathname + window.location.search
+ );
+ }}
>
Log in with AniList
</a>