From 6539f0802e0e43cb1d05c9e1f4643312d3695398 Mon Sep 17 00:00:00 2001 From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de> Date: Sun, 6 Jan 2019 20:04:56 +0100 Subject: [PATCH] fixes #129 --- frontend/src/components/AutoLogout.vue | 6 +++--- frontend/src/store/modules/authentication.ts | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/AutoLogout.vue b/frontend/src/components/AutoLogout.vue index 44af1434..7572dd86 100644 --- a/frontend/src/components/AutoLogout.vue +++ b/frontend/src/components/AutoLogout.vue @@ -72,13 +72,13 @@ export default { }, mounted () { this.timer = setInterval(() => { - const timeToLogOutDialog = Math.min(600 * 1e3, + const timeDialogAppearsBeforeLogout = Math.min(600 * 1e3, 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) { this.logoutDialog = false 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 } } diff --git a/frontend/src/store/modules/authentication.ts b/frontend/src/store/modules/authentication.ts index f5aa875d..ac97806f 100644 --- a/frontend/src/store/modules/authentication.ts +++ b/frontend/src/store/modules/authentication.ts @@ -60,6 +60,7 @@ function SET_MESSAGE (state: AuthState, message: string) { } function SET_JWT_TOKEN (state: AuthState, token: string) { window.sessionStorage.setItem('token', token) + api.default.defaults.headers['Authorization'] = `JWT ${token}` state.token = token } function SET_JWT_TIME_DELTA (state: AuthState, timeDelta: number) { -- GitLab