neutral-old/public/javascripts/dashboard.js
2023-02-18 22:09:04 +01:00

32 lines
647 B
JavaScript

const logoutBtn = document.getElementById("logout")
logoutBtn.addEventListener("click", () => {
fetch('/signout', {
method: 'GET',
redirect: 'follow',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
})
.then(response => response.json())
.then(response => redirect(response))
function redirect(response) {
if(response.success == true) {
window.location.href = "/login"
} else if(response.token == "auth_success") {
window.location.href = "/"
}
}
})