add checktoken interceptors and remove loop refresh

This commit is contained in:
Valentin CZERYBA 2022-07-25 23:46:32 +02:00
parent e208c55811
commit 950669bd0e
3 changed files with 17 additions and 4 deletions

View File

@ -24,6 +24,7 @@
<link rel="mask-icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/safari-pinned-tab.svg" color="#712cf9">
<link rel="icon" href="https://getbootstrap.com/docs/5.2/assets/img/favicons/favicon.ico">
<meta name="theme-color" content="#712cf9">
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<style>
@ -280,8 +281,9 @@
<script src="../js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
<script src="../js/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script><script src="Dashboard%20Template%20%C2%B7%20Bootstrap%20v5_files/Chart.min.js" integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha" crossorigin="anonymous"></script><script src="Dashboard%20Template%20%C2%B7%20Bootstrap%20v5_files/dashboard.js"></script>
<script src="../js/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
<script src="js/config.js"></script>
<script src="js/library.js"></script>
<script src="../js/config.js"></script>
<script src="../js/library.js"></script>
<script src="../js/home.js"></script>
</body></html>

6
web/js/home.js Normal file
View File

@ -0,0 +1,6 @@
checkToken();
const requestInterceptors = axios.interceptors.request.use(function(){
checkToken();
});

View File

@ -1,7 +1,12 @@
function checkToken(){
instance.get("token", { withCredentials: true})
.then(function(response) { location.href="html/home.html"; })
.then(function(response) {
if(location.href.pathname == "/")
{
location.href="/html/home.html";
}
})
.catch(function(error){
location.href="/";
});