Skip to content
Snippets Groups Projects
Commit 6539f080 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

fixes #129

parent 2c91e293
No related branches found
No related tags found
1 merge request!128Merge improve testing
Pipeline #86787 failed
...@@ -72,13 +72,13 @@ export default { ...@@ -72,13 +72,13 @@ export default {
}, },
mounted () { mounted () {
this.timer = setInterval(() => { this.timer = setInterval(() => {
const timeToLogOutDialog = Math.min(600 * 1e3, const timeDialogAppearsBeforeLogout = Math.min(600 * 1e3,
this.jwtTimeDelta ? this.jwtTimeDelta * 0.3 : Infinity) this.jwtTimeDelta ? this.jwtTimeDelta * 0.3 : Infinity)
if (this.$route.name !== 'login' && this.$store.getters.isLoggedIn) { if (this.$route.name !== 'login' && Authentication.isLoggedIn) {
if (Date.now() > this.lastTokenRefreshTry + this.jwtTimeDelta) { if (Date.now() > this.lastTokenRefreshTry + this.jwtTimeDelta) {
this.logoutDialog = false this.logoutDialog = false
actions.logout("You've been logged out due to inactivity.") actions.logout("You've been logged out due to inactivity.")
} else if (Date.now() + timeToLogOutDialog > this.lastTokenRefreshTry + this.jwtTimeDelta) { } else if (Date.now() + timeDialogAppearsBeforeLogout > this.lastTokenRefreshTry + this.jwtTimeDelta) {
this.logoutDialog = true this.logoutDialog = true
} }
} }
......
...@@ -60,6 +60,7 @@ function SET_MESSAGE (state: AuthState, message: string) { ...@@ -60,6 +60,7 @@ function SET_MESSAGE (state: AuthState, message: string) {
} }
function SET_JWT_TOKEN (state: AuthState, token: string) { function SET_JWT_TOKEN (state: AuthState, token: string) {
window.sessionStorage.setItem('token', token) window.sessionStorage.setItem('token', token)
api.default.defaults.headers['Authorization'] = `JWT ${token}`
state.token = token state.token = token
} }
function SET_JWT_TIME_DELTA (state: AuthState, timeDelta: number) { function SET_JWT_TIME_DELTA (state: AuthState, timeDelta: number) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment