some more authentik stuff
This commit is contained in:
parent
0901e242eb
commit
5fc9cf25c8
9
src/routes/+page.server.ts
Normal file
9
src/routes/+page.server.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { PageServerLoad } from "./$types";
|
||||
|
||||
export const load: PageServerLoad = async (event) => {
|
||||
const { user } = event.locals;
|
||||
|
||||
return {
|
||||
user
|
||||
};
|
||||
};
|
@ -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}
|
||||
|
14
src/routes/user/+page.server.ts
Normal file
14
src/routes/user/+page.server.ts
Normal 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
|
||||
};
|
||||
};
|
23
src/routes/user/+page.svelte
Normal file
23
src/routes/user/+page.svelte
Normal 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>
|
Loading…
x
Reference in New Issue
Block a user