2021-07-23 14:30:24 +00:00
|
|
|
//VARIBLES
|
|
|
|
|
2021-07-23 19:41:55 +00:00
|
|
|
// //IF NOT LOGGED IN DON'T SHOW LOG IN BUTTON
|
|
|
|
// if (username === '') {
|
|
|
|
// document.getElementById("logoutlink").style.display = "none";
|
|
|
|
// }
|
2021-07-23 14:30:24 +00:00
|
|
|
|
|
|
|
//LOGOUT FETCH FUNCTION
|
|
|
|
|
|
|
|
async function logout() {
|
2021-07-24 14:10:41 +00:00
|
|
|
let sendLogoutInfo = { "name": username }
|
|
|
|
fetch('/api/logout/', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
2021-07-23 14:30:24 +00:00
|
|
|
},
|
2021-07-24 14:10:41 +00:00
|
|
|
body: JSON.stringify(sendLogoutInfo),
|
|
|
|
});
|
|
|
|
document.querySelector("#errormessage").innerHTML = 'Logged out.'
|
|
|
|
localStorage.removeItem('username')
|
|
|
|
username = null;
|
|
|
|
loggedIn()
|
2021-07-23 19:41:55 +00:00
|
|
|
}
|