Files
overlord/Overlord-Server/public/assets/logout.js
T

20 lines
475 B
JavaScript
Raw Normal View History

2026-03-05 00:04:26 -06:00
window.handleLogout = async function () {
if (!confirm("Are you sure you want to logout?")) return;
try {
const res = await fetch("/api/logout", {
method: "POST",
headers: { "Content-Type": "application/json" },
});
if (res.ok) {
window.location.href = "/";
} else {
alert("Logout failed. Please try again.");
}
} catch (err) {
console.error("Logout error:", err);
alert("Logout failed. Please try again.");
}
};