three60/src/routes/register/+page.server.ts
Markus Brueckner 1547af6ae0 Initial commit
2024-11-25 08:40:14 +01:00

21 lines
No EOL
643 B
TypeScript

import { hash } from '@node-rs/argon2';
import type { Actions } from './$types';
import { usersTable } from '../../db/schema';
import { db } from '../../db';
import { redirect } from '@sveltejs/kit';
export const actions = {
default: async (event) => {
const formData = await event.request.formData();
const email = formData.get('email');
const password = formData.get('password');
const hashedPassword = await hash(password);
await db.insert(usersTable).values({
email,
password_hash: hashedPassword
});
redirect(303, '/login');
}
} satisfies Actions;