feat: enhance OTP verification flow with error handling and response checks
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m20s

This commit is contained in:
i701 2025-04-18 11:57:20 +05:00
parent 25404b66f7
commit 0b2dcfcc01
Signed by: i701
GPG Key ID: 54A0DA1E26D8E587

View File

@ -1,4 +1,6 @@
import VerifyRegistrationOTPForm from "@/components/auth/verify-registration-otp-form"; import VerifyRegistrationOTPForm from "@/components/auth/verify-registration-otp-form";
import { checkIdOrPhone } from "@/queries/authentication";
import { tryCatch } from "@/utils/tryCatch";
import Image from "next/image"; import Image from "next/image";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import React from "react"; import React from "react";
@ -16,7 +18,12 @@ export default async function VerifyRegistrationOTP({
"phone number from server page params (verify otp page)", "phone number from server page params (verify otp page)",
phone_number, phone_number,
); );
const [error, response] = await tryCatch(checkIdOrPhone({ phone_number }));
if (error) {
console.log("Error in checkIdOrPhone", error);
return redirect("/auth/signin");
}
if (response.verified || !response.verified) redirect("/auth/signin");
return ( return (
<div className="bg-gray-100 dark:bg-black w-full h-screen flex items-center justify-center font-sans"> <div className="bg-gray-100 dark:bg-black w-full h-screen flex items-center justify-center font-sans">
<div className="flex flex-col items-center justify-center w-full h-full "> <div className="flex flex-col items-center justify-center w-full h-full ">