Co-authored-by: wolfoftyreso-debug <250630591+wolfoftyreso-debug@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-07-12 14:03:15 +00:00
parent 5df1ce68fa
commit 77aa579ee4
+27
View File
@@ -206,6 +206,33 @@ const PlansSection = () => {
setSubmitting(true); setSubmitting(true);
try { try {
// Auto-create account for guests, then sign in
if (!user && form.password) {
const { data: accData, error: accErr } = await supabase.functions.invoke("create-account", {
body: {
email: result.data.epost,
password: form.password,
company: result.data.företag,
phone: result.data.telefon ?? "",
},
});
if (accErr) throw accErr;
if ((accData as any)?.error) throw new Error((accData as any).error);
const { error: signInErr } = await supabase.auth.signInWithPassword({
email: result.data.epost,
password: form.password,
});
if (signInErr) {
if ((accData as any)?.existed) {
throw new Error(
"Ett konto finns redan för denna e-post. Fel lösenord — logga in eller använd 'Glömt lösenord'.",
);
}
throw signInErr;
}
}
const body = { const body = {
method, method,
employees, employees,