some more authentik stuff

This commit is contained in:
Yuri Tatishchev 2024-10-31 02:38:33 -07:00
parent 0901e242eb
commit 5fc9cf25c8
Signed by: CaZzzer
GPG Key ID: 28BE602058C08557
5 changed files with 55 additions and 2 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -0,0 +1,9 @@
import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async (event) => {
const { user } = event.locals;
return {
user
};
};

View File

@ -1,7 +1,14 @@
<script lang="ts">
import { AuthForm } from "$lib/components/app/auth-form";
import { AuthForm } from '$lib/components/app/auth-form';
const { data } = $props();
const { user } = data;
</script>
<h1>Welcome to SvelteKit</h1>
<AuthForm />
{#if user }
<p>Hi {user.name}</p>
{:else}
<AuthForm class="p-4" />
{/if}

View File

@ -0,0 +1,14 @@
import { redirect } from "@sveltejs/kit";
import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async (event) => {
const { user } = event.locals;
if (!user) {
return redirect(302, "/");
}
return {
user
};
};

View File

@ -0,0 +1,23 @@
<script lang="ts">
import { invalidate, invalidateAll } from '$app/navigation';
import { Button } from '$lib/components/ui/button';
let { data } = $props();
function refetch() {
console.log("refetching");
invalidate((url) => {
console.log("invalidation url", url);
return true;
});
invalidateAll();
}
</script>
<p>
{JSON.stringify(data.user)}
</p>
<Button onclick={refetch}>
Invalidate Data
</Button>