mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-04-20 03:50:20 +00:00
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
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m32s
This commit is contained in:
parent
f3f5800df6
commit
923887b559
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user