mirror of
https://github.com/bartvdbraak/omnidash.git
synced 2025-04-27 23:41:21 +00:00
24 lines
689 B
TypeScript
24 lines
689 B
TypeScript
import { error, redirect } from '@sveltejs/kit';
|
|
|
|
export const actions = {
|
|
default: async ({ request, locals }: { request: Request; locals: App.Locals }) => {
|
|
const body = Object.fromEntries(await request.formData());
|
|
|
|
try {
|
|
const email = body.email.toString();
|
|
const password = body.password.toString();
|
|
await locals.pocketBase.collection('users').authWithPassword(email, password);
|
|
if (!locals.pocketBase?.authStore?.model?.verified) {
|
|
locals.pocketBase.authStore.clear();
|
|
return {
|
|
notVerified: true
|
|
};
|
|
}
|
|
} catch (err) {
|
|
console.log('Error: ', err);
|
|
throw error(500, 'Something went wrong logging in');
|
|
}
|
|
|
|
throw redirect(303, '/');
|
|
}
|
|
};
|