feat: initial logins

This commit is contained in:
2025-06-12 13:58:59 +01:00
parent b516196d38
commit 3bdee89eed
12 changed files with 716 additions and 444 deletions

View File

@@ -0,0 +1,30 @@
import { redirect, error } from "@sveltejs/kit";
import type { Actions } from "./$types";
export const actions: Actions = {
signup: async ({ request, locals: { supabase } }) => {
const formData = await request.formData();
const email = formData.get("email") as string;
const password = formData.get("password") as string;
const { error: authError } = await supabase.auth.signUp({ email, password });
if (authError) {
error(400, "Failed to sign up: " + authError.message);
} else {
redirect(303, "/");
}
},
login: async ({ request, locals: { supabase } }) => {
const formData = await request.formData();
const email = formData.get("email") as string;
const password = formData.get("password") as string;
const { error: authError } = await supabase.auth.signInWithPassword({ email, password });
if (authError) {
error(400, "Failed to log in: " + authError.message);
} else {
redirect(303, "/");
}
}
};