logout is now possible again
This commit is contained in:
@@ -4,6 +4,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
const dropdownMenu = document.getElementById('dropdown-menu');
|
const dropdownMenu = document.getElementById('dropdown-menu');
|
||||||
const menuBtn = document.getElementById('menu-btn');
|
const menuBtn = document.getElementById('menu-btn');
|
||||||
const mainNav = document.getElementById('main-nav');
|
const mainNav = document.getElementById('main-nav');
|
||||||
|
const logoutBtn = document.getElementById('logout-btn');
|
||||||
|
|
||||||
if (profileBtn && dropdownMenu) {
|
if (profileBtn && dropdownMenu) {
|
||||||
profileBtn.addEventListener('click', (e) => {
|
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 (dropdownMenu) dropdownMenu.classList.remove('show');
|
||||||
if (mainNav) mainNav.classList.remove('show');
|
if (mainNav) mainNav.classList.remove('show');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{{ define "base.html" }}
|
{{ define "base.html" }}
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
@@ -39,7 +38,7 @@
|
|||||||
<a href="/profile/settings">Account Settings</a>
|
<a href="/profile/settings">Account Settings</a>
|
||||||
<a href="/profile/activity">Activity Log</a>
|
<a href="/profile/activity">Activity Log</a>
|
||||||
<hr class="dropdown-divider">
|
<hr class="dropdown-divider">
|
||||||
<button class="logout-btn"
|
<button id="logout-btn" class="logout-btn"
|
||||||
hx-post="/api/logout"
|
hx-post="/api/logout"
|
||||||
hx-on::after-request="window.location.href='/login'">
|
hx-on::after-request="window.location.href='/login'">
|
||||||
Log Out
|
Log Out
|
||||||
@@ -53,7 +52,6 @@
|
|||||||
{{ template "content" . }}
|
{{ template "content" . }}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script src="/assets/js/api.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
Reference in New Issue
Block a user