From d643a8f22946c219b809e11210b9f874e972bfa0 Mon Sep 17 00:00:00 2001 From: NotII <46204250+NotII@users.noreply.github.com> Date: Fri, 7 Mar 2025 02:36:09 +0000 Subject: [PATCH] Update page.tsx --- app/auth/login/page.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/auth/login/page.tsx b/app/auth/login/page.tsx index 41e4cbf..7ee7201 100644 --- a/app/auth/login/page.tsx +++ b/app/auth/login/page.tsx @@ -48,21 +48,16 @@ export default function LoginPage() { const data = await response.json(); if (response.ok && data.token) { - // Set redirecting state to prevent multiple redirect attempts setIsRedirecting(true); - // Store the token in both cookie and localStorage for redundancy document.cookie = `Authorization=${data.token}; path=/; Secure; SameSite=Strict; max-age=604800`; localStorage.setItem("Authorization", data.token); - // Show toast before redirect toast.success("Login successful"); - // Use a small timeout to ensure the cookie is set before navigation setTimeout(() => { try { router.push("/dashboard"); - // Force a hard redirect if router.push doesn't work setTimeout(() => { window.location.href = "/dashboard"; }, 1000); @@ -72,14 +67,12 @@ export default function LoginPage() { } }, 300); } else { - // Handle HTTP error responses (including 401) const errorMessage = data.error || "Invalid credentials"; toast.error("Login Failed", { description: errorMessage, }); } } catch (error) { - // This will now only catch network errors or JSON parsing errors toast.error("Connection Error", { description: "Unable to connect to the server. Please check your internet connection and try again.", }); @@ -89,7 +82,6 @@ export default function LoginPage() { } } - // If already redirecting, show loading state if (isRedirecting) { return (