refactor(auth): extract saltRounds constant

This commit is contained in:
cfngc4594 2025-03-14 17:15:38 +08:00
parent 116519a70b
commit cd50e73fc9

View File

@ -6,13 +6,15 @@ import { signIn } from "@/lib/auth";
import { authSchema } from "@/lib/zod"; import { authSchema } from "@/lib/zod";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
const saltRounds = 10;
export async function signInWithCredentials(formData: { email: string; password: string }) { export async function signInWithCredentials(formData: { email: string; password: string }) {
await signIn("credentials", formData); await signIn("credentials", formData);
} }
export async function signUpWithCredentials(formData: { email: string; password: string }) { export async function signUpWithCredentials(formData: { email: string; password: string }) {
const validatedData = await authSchema.parseAsync(formData); const validatedData = await authSchema.parseAsync(formData);
const saltRounds = 10;
const pwHash = await bcrypt.hash(validatedData.password, saltRounds); const pwHash = await bcrypt.hash(validatedData.password, saltRounds);
await prisma.user.create({ await prisma.user.create({