jwt refresh token 1.0

This commit is contained in:
2025-09-21 17:49:55 +03:00
parent 639bc3c1a9
commit 5ddab94773
8 changed files with 95 additions and 19 deletions

View File

@@ -9,6 +9,9 @@
<body>
<div class="glass-container">
<div class="data-box">
<form id="logoutForm">
<button type="submit">Logout</button>
</form>
<h2>data</h2>
<form action="#" method="POST">
<p>Data</p>

View File

@@ -1,4 +1,13 @@
const token = localStorage.getItem("token");
if (!token) {
window.location.href = "./../login/index.html";
}
function tokenCheck(){
const token = localStorage.getItem("token") || sessionStorage.getItem("token");
if (!token) {
window.location.href = "./../login/index.html";
}
}
tokenCheck()
document.getElementById('logoutForm').addEventListener('submit', async function (e) {
e.preventDefault();
localStorage.removeItem("token");
tokenCheck();
});

View File

@@ -58,3 +58,17 @@ p {
color: #fff;
margin-top: 15px;
}
button {
background: #fff;
color: black;
padding: 10px;
border: none;
border-radius: 10px;
cursor: pointer;
margin-top: 15px;
}
button:hover {
background: transparent;
color: white;
outline: 1px solid #fff;
}