neutral-old/public/javascripts/dashboard.js

32 lines
647 B
JavaScript
Raw Normal View History

2023-02-18 21:09:04 +00:00
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 = "/"
}
}
})