diff --git a/frontend/assets/js/api.js b/frontend/assets/js/api.js index 8d191bb..f966733 100644 --- a/frontend/assets/js/api.js +++ b/frontend/assets/js/api.js @@ -4,6 +4,7 @@ document.addEventListener("DOMContentLoaded", () => { const dropdownMenu = document.getElementById('dropdown-menu'); const menuBtn = document.getElementById('menu-btn'); const mainNav = document.getElementById('main-nav'); + const logoutBtn = document.getElementById('logout-btn'); if (profileBtn && dropdownMenu) { profileBtn.addEventListener('click', (e) => { @@ -22,7 +23,15 @@ document.addEventListener("DOMContentLoaded", () => { }); } - window.addEventListener('click', () => { + logoutBtn.addEventListener('click', () => { + console.log("Logout") + localStorage.removeItem('access_token'); + localStorage.removeItem('refresh_token'); + document.cookie = "access_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;"; + document.cookie = "refresh_token=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;"; + }); + + document.addEventListener('click', () => { if (dropdownMenu) dropdownMenu.classList.remove('show'); if (mainNav) mainNav.classList.remove('show'); }); diff --git a/frontend/htmx/contents/dash/base.html b/frontend/htmx/contents/dash/base.html index 4c72794..da3f6b1 100644 --- a/frontend/htmx/contents/dash/base.html +++ b/frontend/htmx/contents/dash/base.html @@ -1,5 +1,4 @@ {{ define "base.html" }} - @@ -39,7 +38,7 @@ Account Settings Activity Log -