32 lines
647 B
JavaScript
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 = "/"
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
})
|