Commit 97f8d2f1 authored by Koen Martens's avatar Koen Martens
Browse files

Frontend: ping server periodically to refresh jwt

parent 671d8a4b
......@@ -35,8 +35,8 @@ export default {
methods: {
logoff() {
this.$store.commit('jwt', null);
}
}
},
},
}
</script>
......
......@@ -25,6 +25,7 @@ export default {
username: '',
password: '',
error: '',
token_expiry: 0,
}
},
watch: {
......@@ -46,6 +47,8 @@ export default {
})
.then(response => {
this.$store.commit('identity', response.data.identity);
this.$data.token_expiry = response.data.token_expiry;
this.keep_auth_alive();
})
.catch(error => {
if (error.response && error.response.status==401) {
......@@ -57,6 +60,20 @@ export default {
},
enter_username() {
this.$refs.password.focus();
},
keep_auth_alive() {
setTimeout(() => {
if(this.$store.getters.authenticated) {
axios.get(this.$store.getters.api_url(['ping']), {
headers: this.$store.getters.auth_headers(),
withCredentials: true
}).then(() => {
this.keep_auth_alive();
}).catch(error => {
console.log(error);
});
}
}, (this.$data.token_expiry/2)*1000);
}
},
computed: {
......
......@@ -130,8 +130,6 @@
this.$refs.roles_table.clearSelected();
},
'role_changed': function(item) {
console.log('role changed');
console.log(item);
let verb = axios.put;
let endpoint = ['roles', item.id];
if(item.id == null) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment