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