refactor(auth): relocate logout handler to main.js
This commit is contained in:
@@ -437,27 +437,7 @@ function initAuth() {
|
||||
submitLogin(formData);
|
||||
});
|
||||
}
|
||||
// handle ?logout=1 query
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (params.get('logout') === '1') {
|
||||
localStorage.removeItem("username");
|
||||
localStorage.removeItem("userTOTPEnabled");
|
||||
}
|
||||
|
||||
// attach logout button listener
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const btn = document.getElementById('logoutBtn');
|
||||
if (!btn) return;
|
||||
btn.addEventListener('click', () => {
|
||||
fetch('/api/auth/logout.php', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: { 'X-CSRF-Token': window.csrfToken }
|
||||
})
|
||||
.then(() => window.location.reload(true))
|
||||
.catch(() => { });
|
||||
});
|
||||
});
|
||||
document.getElementById("addUserBtn").addEventListener("click", function () {
|
||||
resetUserForm();
|
||||
toggleVisibility("addUserModal", true);
|
||||
|
||||
Reference in New Issue
Block a user