feat: integrate checkTempIdOrPhone in signup logic to validate temporary phone numbers
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m32s

This commit is contained in:
i701 2025-04-18 14:35:34 +05:00
parent f3f5800df6
commit 923887b559
Signed by: i701
GPG Key ID: 54A0DA1E26D8E587

View File

@ -1,7 +1,11 @@
"use server";
import { signUpFormSchema } from "@/lib/schemas";
import { backendRegister, checkIdOrPhone } from "@/queries/authentication";
import {
backendRegister,
checkIdOrPhone,
checkTempIdOrPhone,
} from "@/queries/authentication";
import { handleApiResponse, tryCatch } from "@/utils/tryCatch";
import { redirect } from "next/navigation";
import { z } from "zod";
@ -133,7 +137,10 @@ export async function signup(_actionState: ActionState, formData: FormData) {
phone_number: parsedData.data.phone_number,
});
if (phoneNumberExists.ok) {
const tempPhoneNumberExists = await checkTempIdOrPhone({
phone_number: parsedData.data.phone_number,
});
if (phoneNumberExists.ok || tempPhoneNumberExists.ok) {
return {
message: "Phone number already exists.",
payload: formData,
@ -160,7 +167,11 @@ export async function signup(_actionState: ActionState, formData: FormData) {
}),
);
if (signupError) {
throw new Error(signupError.message);
return {
message: signupError.message,
payload: formData,
db_error: "phone_number",
};
}
console.log("SIGNUP RESPONSE", signupResponse);