jwt refresh token 1.0
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user