feat: v1 — persistent shell, model gateway, artifact improvements (#1462)
This commit is contained in:
parent
3651670fb9
commit
f9652b452a
161 changed files with 5166 additions and 8009 deletions
|
|
@ -1,7 +1,10 @@
|
|||
"use server";
|
||||
|
||||
import { z } from "zod";
|
||||
import { auth } from "@/lib/auth";
|
||||
|
||||
import { createUser, getUser } from "@/lib/db/queries";
|
||||
|
||||
import { signIn } from "./auth";
|
||||
|
||||
const authFormSchema = z.object({
|
||||
email: z.string().email(),
|
||||
|
|
@ -22,11 +25,10 @@ export const login = async (
|
|||
password: formData.get("password"),
|
||||
});
|
||||
|
||||
await auth.api.signInEmail({
|
||||
body: {
|
||||
email: validatedData.email,
|
||||
password: validatedData.password,
|
||||
},
|
||||
await signIn("credentials", {
|
||||
email: validatedData.email,
|
||||
password: validatedData.password,
|
||||
redirect: false,
|
||||
});
|
||||
|
||||
return { status: "success" };
|
||||
|
|
@ -59,17 +61,17 @@ export const register = async (
|
|||
password: formData.get("password"),
|
||||
});
|
||||
|
||||
const result = await auth.api.signUpEmail({
|
||||
body: {
|
||||
email: validatedData.email,
|
||||
password: validatedData.password,
|
||||
name: validatedData.email,
|
||||
},
|
||||
});
|
||||
const [user] = await getUser(validatedData.email);
|
||||
|
||||
if (!result) {
|
||||
return { status: "failed" };
|
||||
if (user) {
|
||||
return { status: "user_exists" } as RegisterActionState;
|
||||
}
|
||||
await createUser(validatedData.email, validatedData.password);
|
||||
await signIn("credentials", {
|
||||
email: validatedData.email,
|
||||
password: validatedData.password,
|
||||
redirect: false,
|
||||
});
|
||||
|
||||
return { status: "success" };
|
||||
} catch (error) {
|
||||
|
|
@ -77,11 +79,6 @@ export const register = async (
|
|||
return { status: "invalid_data" };
|
||||
}
|
||||
|
||||
const message = error instanceof Error ? error.message : "";
|
||||
if (message.includes("already exists") || message.includes("UNIQUE")) {
|
||||
return { status: "user_exists" };
|
||||
}
|
||||
|
||||
return { status: "failed" };
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue