nagasurendra commited on
Commit
81b3821
·
verified ·
1 Parent(s): 80bae4f

Update templates/dashboard.html

Browse files
Files changed (1) hide show
  1. templates/dashboard.html +7 -3
templates/dashboard.html CHANGED
@@ -13,16 +13,20 @@
13
  }
14
 
15
  function logout() {
16
- window.location.href = "/logout"; // Redirect to logout
 
 
 
 
17
  }
18
 
19
- // Reset timer on user activity
20
  document.addEventListener("mousemove", resetTimer);
21
  document.addEventListener("keydown", resetTimer);
22
  document.addEventListener("click", resetTimer);
23
  document.addEventListener("touchstart", resetTimer);
24
 
25
- // Initialize the timer when the page loads
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>