Spaces:
Sleeping
Sleeping
Update templates/dashboard.html
Browse files- templates/dashboard.html +7 -3
templates/dashboard.html
CHANGED
|
@@ -13,16 +13,20 @@
|
|
| 13 |
}
|
| 14 |
|
| 15 |
function logout() {
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
|
| 19 |
-
//
|
| 20 |
document.addEventListener("mousemove", resetTimer);
|
| 21 |
document.addEventListener("keydown", resetTimer);
|
| 22 |
document.addEventListener("click", resetTimer);
|
| 23 |
document.addEventListener("touchstart", resetTimer);
|
| 24 |
|
| 25 |
-
//
|
| 26 |
resetTimer();
|
| 27 |
</script>
|
| 28 |
</head>
|
|
|
|
| 13 |
}
|
| 14 |
|
| 15 |
function logout() {
|
| 16 |
+
fetch('/logout', { method: 'GET' }) // Call Flask logout route
|
| 17 |
+
.then(response => {
|
| 18 |
+
window.location.href = "/login"; // Redirect to login page
|
| 19 |
+
})
|
| 20 |
+
.catch(error => console.error("Logout failed", error));
|
| 21 |
}
|
| 22 |
|
| 23 |
+
// Listen for user activity and reset the timer
|
| 24 |
document.addEventListener("mousemove", resetTimer);
|
| 25 |
document.addEventListener("keydown", resetTimer);
|
| 26 |
document.addEventListener("click", resetTimer);
|
| 27 |
document.addEventListener("touchstart", resetTimer);
|
| 28 |
|
| 29 |
+
// Start the inactivity timer on page load
|
| 30 |
resetTimer();
|
| 31 |
</script>
|
| 32 |
</head>
|