Skip to content

Commit 933758c

Browse files
author
jas023
committed
change
1 parent f7e984e commit 933758c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

auth.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,17 @@ document.addEventListener('DOMContentLoaded', () => {
8686
if (logoutButton) {
8787
logoutButton.addEventListener("click", handleLogout);
8888
}
89-
});
89+
});
90+
if (!user && window.location.pathname !== "/login") {
91+
window.location.href = "/login";
92+
}
93+
form.addEventListener("submit", (e) => {
94+
e.preventDefault(); // stops auto refresh
95+
// handle login/signup
96+
});
97+
useEffect(() => {
98+
if (user) {
99+
navigate("/dashboard");
100+
}
101+
}, [user]);
102+
localStorage.setItem("authToken", token);

0 commit comments

Comments
 (0)