Update page.tsx

This commit is contained in:
NotII
2025-03-07 01:54:46 +00:00
parent a56bb7891e
commit 65fcf2613a

View File

@@ -30,9 +30,16 @@ export default function LoginPage() {
const data = await response.json(); 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) { if (response.ok && data.token) {
document.cookie = `Authorization=${data.token}; path=/; Secure; SameSite=Strict; max-age=604800`; document.cookie = `Authorization=${data.token}; path=/; Secure; SameSite=Strict; max-age=604800`;
router.push("/dashboard"); router.push("/dashboard");
toast.success("Login successful, if you are not redirected change /auth/login to /dashboard");
} else { } else {
// Handle HTTP error responses (including 401) // Handle HTTP error responses (including 401)
const errorMessage = data.error || "Invalid credentials"; const errorMessage = data.error || "Invalid credentials";