added logout

This commit is contained in:
TheUnrealDragon 2025-12-28 18:11:32 +05:30
commit 74ac3f86f1

View file

@ -10,8 +10,32 @@
<script src="{{ url_for('static', path='/jquery.js') }}">
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script>
function logout() {
fetch("/api/users/logout", {
method: "POST",
body: JSON.stringify({
username: getCookie("username"),
session_key: getCookie("session_key"),
redirect: "/server",
password: ""
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
},
redirect: "follow"
})
}
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
</script>
<div align="center">
<h3>Server Manager, Welcome {{ username }} </h3>
<a href="/api/users/logout" onclick="location.href=this.href+'?username='+getCookie('username')+'&session_key='+getCookie('session_key')+'&redirect=/server';return false;">Logout</a>
</div>
<br>
<br>