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, "/"); } } };