46 lines
1.2 KiB
HTML
46 lines
1.2 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<body>
|
|
<div id="content">
|
|
<h1>User Management</h1>
|
|
<p>Welcome, {{ email }}</p>
|
|
</div>
|
|
|
|
<div id="menu">
|
|
<button id="adminBtn">Admin</button>
|
|
<button id="logoutBtn">Logout</button>
|
|
</div>
|
|
|
|
<script>
|
|
document
|
|
.getElementById("logoutBtn")
|
|
.addEventListener("click", function () {
|
|
// Remove the cookie by setting its value to an empty string and its expiry date to the past.
|
|
fetch("/web-api/logout", {
|
|
method: "POST",
|
|
credentials: "same-origin",
|
|
})
|
|
.then((response) => {
|
|
if (!response.ok) {
|
|
throw new Error(
|
|
`Network response was not ok: ${response.statusText}`,
|
|
);
|
|
}
|
|
window.location.href = "/web/login";
|
|
})
|
|
.catch((error) => {
|
|
console.error(
|
|
`There was a problem with the fetch operation: ${error}`,
|
|
);
|
|
});
|
|
});
|
|
|
|
document
|
|
.getElementById("adminBtn")
|
|
.addEventListener("click", function () {
|
|
window.location.href = "/web/admin";
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|