26 lines
575 B
JavaScript
26 lines
575 B
JavaScript
import { createUserSession } from "$lib/server/db/user";
|
|
|
|
/** @type {import("@sveltejs/kit").Action} */
|
|
async function POST({ request, cookies }) {
|
|
if (request.method !== 'POST') {
|
|
return;
|
|
}
|
|
|
|
const data = await request.formData();
|
|
const username = data.get('username')?.toString();
|
|
const password = data.get('password')?.toString();
|
|
|
|
if (!username || !password) {
|
|
return;
|
|
}
|
|
|
|
const result = await createUserSession(username, password);
|
|
|
|
console.log(result);
|
|
}
|
|
|
|
/** @type {import("@sveltejs/kit").Actions} */
|
|
export let actions = {
|
|
default: POST
|
|
};
|