From 6f692a54a896a3f02549222e41c23cd2409887e7 Mon Sep 17 00:00:00 2001 From: allinix Date: Tue, 18 Feb 2025 19:02:38 +0530 Subject: [PATCH] signin update --- next/src/pages/index.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/next/src/pages/index.tsx b/next/src/pages/index.tsx index 47301f0..ace8f1c 100644 --- a/next/src/pages/index.tsx +++ b/next/src/pages/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/navigation"; @@ -8,12 +8,14 @@ const signin: React.FC = () => { const router = useRouter(); const { login, authenticated, ready } = usePrivy(); - const handleAccess = () => { - if (authenticated) { + useEffect(() => { + if (ready && authenticated) { router.push("/chat"); - } else { - login(); } + }, [authenticated, ready, router]); + + const handleAccess = () => { + login(); }; return ( @@ -67,4 +69,4 @@ const signin: React.FC = () => { ); }; -export default signin; +export default signin; \ No newline at end of file