From 3ce4661f1b9f97730cfc0750ebe7a8b3e92c9f03 Mon Sep 17 00:00:00 2001 From: Sourabh782 Date: Tue, 15 Oct 2024 08:52:09 +0530 Subject: [PATCH] resolved password not resetting issue --- src/app/auth/page.tsx | 7 ++++++- src/app/layout.tsx | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/auth/page.tsx b/src/app/auth/page.tsx index 325179d..65bdc43 100644 --- a/src/app/auth/page.tsx +++ b/src/app/auth/page.tsx @@ -1,5 +1,5 @@ "use client"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import styles from "./page.module.css"; @@ -19,10 +19,15 @@ export default function Auth() { register, handleSubmit, formState: { errors }, + reset, } = useForm({ resolver: zodResolver(isSignup ? signupSchema : loginSchema), }); + useEffect(() => { + reset(); + }, [isSignup, reset]); + console.log(callback); const onSubmit = async (data: any) => { diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 27edf1f..c0a15e9 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -65,7 +65,8 @@ export default async function RootLayout({ const pathname = h.get("x-current-path"); if (session) { - if (!session.user.emailVerified) { + console.log(session) + if (!session.user?.emailVerified) { if (!pathname!.includes("/auth")) { redirect("/auth/verify"); }