Skip to content

Commit bb7d0a1

Browse files
committed
m
1 parent 293bd2d commit bb7d0a1

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

server/frontend/package-lock.json

Lines changed: 27 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/frontend/static/Home.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,29 @@
2323
'<a class="homepage_links" href="/register">Register</a>'
2424
}
2525
}
26+
27+
28+
// Build logout URL and Make GET request to logout endpoint
29+
let logout_url = window.location.origin+"/djangoapp/logout";
30+
const res = await fetch(logout_url, {
31+
method: "GET",
32+
});
33+
34+
const json = await res.json();
35+
if (json) {
36+
// Clear session storage and reload page
37+
let username = sessionStorage.getItem('username');
38+
sessionStorage.removeItem('username');
39+
window.location.href = window.location.origin;
40+
window.location.reload();
41+
// Notify user of logout
42+
alert("Logging out "+username+"...")
43+
}
44+
else {
45+
alert("The user could not be logged out.")
46+
}
47+
48+
2649
</script>
2750
</head>
2851
<body onload="checkSession()">

0 commit comments

Comments
 (0)