mirror of
https://github.com/tale/headplane.git
synced 2026-08-25 20:06:48 +00:00
d2c4f5eb2b
* Cookies are now encrypted JWTs (GHSA-wrqq-v7qw-r5w7) * Authentication is stored in the SQLite database (auto-migrated) * Session logic is much cleaner
24 lines
525 B
TypeScript
24 lines
525 B
TypeScript
import { eq } from 'drizzle-orm';
|
|
import { LoaderFunctionArgs, redirect } from 'react-router';
|
|
import { LoadContext } from '~/server';
|
|
import { users } from '~/server/db/schema';
|
|
|
|
export async function loader({
|
|
request,
|
|
context,
|
|
}: LoaderFunctionArgs<LoadContext>) {
|
|
try {
|
|
const { user } = await context.sessions.auth(request);
|
|
await context.db
|
|
.update(users)
|
|
.set({
|
|
onboarded: true,
|
|
})
|
|
.where(eq(users.sub, user.subject));
|
|
|
|
return redirect('/machines');
|
|
} catch {
|
|
return redirect('/login');
|
|
}
|
|
}
|