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"); }