mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-13 02:53:45 +00:00
feat(*): Add sign in route with redirection to mydex
This commit is contained in:
@@ -137,6 +137,7 @@
|
|||||||
>
|
>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown dropdown-end">
|
<div class="dropdown dropdown-end">
|
||||||
|
{#if localUser}
|
||||||
<div tabindex="0" role="button" class="btn btn-ghost btn-circle avatar">
|
<div tabindex="0" role="button" class="btn btn-ghost btn-circle avatar">
|
||||||
<div class="w-10 rounded-full">
|
<div class="w-10 rounded-full">
|
||||||
<img alt="usericon" src="/OIG5.jpg" />
|
<img alt="usericon" src="/OIG5.jpg" />
|
||||||
@@ -159,6 +160,9 @@
|
|||||||
<li><SignIn {supabase} on:signedIn={getUser} /></li>
|
<li><SignIn {supabase} on:signedIn={getUser} /></li>
|
||||||
{/if}
|
{/if}
|
||||||
</ul>
|
</ul>
|
||||||
|
{:else}
|
||||||
|
<a href="/signin">Sign In</a>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -149,7 +149,10 @@
|
|||||||
<title>Living Dex Tracker - My Dex</title>
|
<title>Living Dex Tracker - My Dex</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex">
|
{#if !localUser}
|
||||||
|
<p>Please <a href="/signin" class="underline text-primary hover:text-secondary">sign in</a></p>
|
||||||
|
{:else}
|
||||||
|
<div class="flex">
|
||||||
<aside class="w-64 bg-gray-800 text-white p-4 fixed h-5/6">
|
<aside class="w-64 bg-gray-800 text-white p-4 fixed h-5/6">
|
||||||
<h2 class="text-2xl font-semibold mb-4">Filters</h2>
|
<h2 class="text-2xl font-semibold mb-4">Filters</h2>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -266,8 +269,8 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<h1>Failed to load</h1>
|
<h1>Failed to load</h1>
|
||||||
<p>
|
<p>
|
||||||
If you're seeing this, you probably haven't created your Pokédex data yet. Please do so
|
If you're seeing this, you probably haven't created your Pokédex data yet. Please do
|
||||||
by clicking this button.
|
so by clicking this button.
|
||||||
</p>
|
</p>
|
||||||
<button class="btn" on:click={createCatchRecords}>Create Pokédex data</button>
|
<button class="btn" on:click={createCatchRecords}>Create Pokédex data</button>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -279,4 +282,5 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onDestroy } from 'svelte';
|
||||||
|
import { user } from '$lib/stores/user.js';
|
||||||
|
import { type User } from '@supabase/auth-js';
|
||||||
|
import SignIn from '$lib/components/SignIn.svelte';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
|
export let data;
|
||||||
|
let { supabase } = data;
|
||||||
|
$: ({ supabase } = data);
|
||||||
|
|
||||||
|
let localUser: User | null;
|
||||||
|
const unsubscribe = user.subscribe((value) => {
|
||||||
|
localUser = value;
|
||||||
|
});
|
||||||
|
onDestroy(unsubscribe);
|
||||||
|
|
||||||
|
async function getUser() {
|
||||||
|
const {
|
||||||
|
data: { session }
|
||||||
|
} = await supabase.auth.getSession();
|
||||||
|
|
||||||
|
if (session) {
|
||||||
|
localUser = session.user;
|
||||||
|
} else {
|
||||||
|
localUser = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
user.set(localUser);
|
||||||
|
goto('/mydex', { replace: true });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<SignIn {supabase} on:signedIn={getUser} />
|
||||||
Reference in New Issue
Block a user