Update page.tsx
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user