jwt refresh token 1.1
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
//Разобраться с хранением и использованием refresh token
|
||||
//Добавить endpoint logout
|
||||
|
||||
const token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
window.location.href = "./../main/index.html";
|
||||
function getToken() {
|
||||
return localStorage.getItem("token") || sessionStorage.getItem("token");
|
||||
}
|
||||
function tokenCheck(){
|
||||
const token = getToken();
|
||||
if (!token) {
|
||||
window.location.href = "./../main/index.html";
|
||||
}
|
||||
}
|
||||
document.getElementById('loginForm').addEventListener('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
function getToken() {
|
||||
return localStorage.getItem("token") || sessionStorage.getItem("token");
|
||||
}
|
||||
function tokenCheck(){
|
||||
const token = localStorage.getItem("token") || sessionStorage.getItem("token");
|
||||
const token = getToken();
|
||||
if (!token) {
|
||||
window.location.href = "./../login/index.html";
|
||||
}
|
||||
@@ -9,5 +12,6 @@ tokenCheck()
|
||||
document.getElementById('logoutForm').addEventListener('submit', async function (e) {
|
||||
e.preventDefault();
|
||||
localStorage.removeItem("token");
|
||||
sessionStorage.removeItem("token");
|
||||
tokenCheck();
|
||||
});
|
||||
Reference in New Issue
Block a user