diff --git a/app/auth/login/page.tsx b/app/auth/login/page.tsx index e93cb44..cc4b5a5 100644 --- a/app/auth/login/page.tsx +++ b/app/auth/login/page.tsx @@ -30,9 +30,16 @@ export default function LoginPage() { const data = await response.json(); + if(data.token) { + toast.success("Login successful, if you are not redirected change /auth/login to /dashboard"); + document.cookie = `Authorization=${data.token}; path=/; Secure; SameSite=Strict; max-age=604800`; + router.push("/dashboard"); + } + if (response.ok && data.token) { document.cookie = `Authorization=${data.token}; path=/; Secure; SameSite=Strict; max-age=604800`; router.push("/dashboard"); + toast.success("Login successful, if you are not redirected change /auth/login to /dashboard"); } else { // Handle HTTP error responses (including 401) const errorMessage = data.error || "Invalid credentials";