fix: logout no longer reloads page, shows message instead
This commit is contained in:
@@ -148,8 +148,13 @@ async function init() {
|
|||||||
listEl.appendChild(a);
|
listEl.appendChild(a);
|
||||||
});
|
});
|
||||||
document.getElementById('logout-btn').onclick = async function(e) {
|
document.getElementById('logout-btn').onclick = async function(e) {
|
||||||
await fetch('/api/v1/auth/logout', {method:'POST'});
|
e.preventDefault();
|
||||||
window.location.reload();
|
e.stopPropagation();
|
||||||
|
try {
|
||||||
|
await fetch('/api/v1/auth/logout', {method:'POST'});
|
||||||
|
} catch(_) {}
|
||||||
|
el.innerHTML = '<p style="color:#060">Logged out. Session cleared.</p>';
|
||||||
|
document.getElementById('logout-btn').style.display = 'none';
|
||||||
};
|
};
|
||||||
var hash = location.hash.slice(1);
|
var hash = location.hash.slice(1);
|
||||||
await loadDoc(hash || '01_auth');
|
await loadDoc(hash || '01_auth');
|
||||||
@@ -158,11 +163,6 @@ async function init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onpopstate = function() {
|
|
||||||
var hash = location.hash.slice(1);
|
|
||||||
if (hash) loadDoc(hash);
|
|
||||||
};
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user