move better-auth demo to auth dir

This commit is contained in:
2026-05-11 13:08:37 +02:00
parent 72337e801c
commit ddfb70adc2
7 changed files with 98 additions and 103 deletions

View File

@@ -0,0 +1,20 @@
import { redirect } from '@sveltejs/kit';
import type { Actions } from './$types';
import type { PageServerLoad } from './$types';
import { auth } from '$lib/server/auth';
export const load: PageServerLoad = (event) => {
if (!event.locals.user) {
return redirect(302, '/auth/login');
}
return { user: event.locals.user };
};
export const actions: Actions = {
signOut: async (event) => {
await auth.api.signOut({
headers: event.request.headers
});
return redirect(302, '/auth/login');
}
};