navbar.js 665 B

1234567891011121314151617181920212223
  1. /**
  2. * Logout functionality.
  3. *
  4. * This script is responsible for removing the user token from local storage and redirecting to the authentication page upon logout click.
  5. */
  6. "use strict";
  7. /**
  8. * Add an event listener to the window's load event.
  9. * This function will be executed when the document has finished loading.
  10. */
  11. window.addEventListener("load", function() {
  12. document.getElementById("logout-button").addEventListener("click", logout);
  13. });
  14. /**
  15. * Removes the user token from local storage and redirects to the authentication page.
  16. */
  17. function logout() {
  18. window.localStorage.removeItem('token');
  19. window.location.replace("/html/auth.html");
  20. }