Initialize web, api and database for this project. Web uses better-auth, paraglide, tailwind, shadcn components, and more. Not much else has been done.
21 lines
531 B
TypeScript
21 lines
531 B
TypeScript
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, '/demo/better-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, '/demo/better-auth/login');
|
|
}
|
|
};
|