fix(auth): update error message for sign-in and sign-up functions

This commit is contained in:
cfngc4594 2025-03-18 23:24:36 +08:00
parent 0e16b9ff6c
commit 919016cf27

View File

@ -4,7 +4,6 @@ import bcrypt from "bcrypt";
import prisma from "@/lib/prisma"; import prisma from "@/lib/prisma";
import { signIn } from "@/lib/auth"; import { signIn } from "@/lib/auth";
import { authSchema } from "@/lib/zod"; import { authSchema } from "@/lib/zod";
import { Prisma } from "@prisma/client";
import { CredentialsSignInFormValues } from "@/components/credentials-sign-in-form"; import { CredentialsSignInFormValues } from "@/components/credentials-sign-in-form";
import { CredentialsSignUpFormValues } from "@/components/credentials-sign-up-form"; import { CredentialsSignUpFormValues } from "@/components/credentials-sign-up-form";
@ -19,7 +18,7 @@ export async function signInWithCredentials(formData: CredentialsSignInFormValue
return { success: true }; return { success: true };
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
return { error: error.message }; return { error: "Invalid credentials" };
} }
return { error: "Failed to sign in. Please try again." }; return { error: "Failed to sign in. Please try again." };
} }
@ -55,11 +54,6 @@ export async function signUpWithCredentials(formData: CredentialsSignUpFormValue
return { success: true }; return { success: true };
} catch (error) { } catch (error) {
if (error instanceof Prisma.PrismaClientKnownRequestError) {
if (error.code === "P2002") {
return { error: "Email already registered" };
}
}
if (error instanceof Error) { if (error instanceof Error) {
return { error: error.message }; return { error: error.message };
} }