From c666f36cf407dddf9e4a4997ae108c6366a0a276 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 7 Apr 2021 16:37:43 +0200 Subject: [PATCH] Only check for token renew when the user is authenticated --- src/components/home/contentAuth.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/home/contentAuth.vue b/src/components/home/contentAuth.vue index ce4b2fd1d..48e009883 100644 --- a/src/components/home/contentAuth.vue +++ b/src/components/home/contentAuth.vue @@ -56,6 +56,7 @@ export default { background: 'background', menuActive: MENU_ACTIVE, userInfo: state => state.auth.info, + authenticated: state => state.auth.authenticated, }), methods: { doStuffAfterRoute() { @@ -88,6 +89,10 @@ export default { // Check if the token is still valid if the window gets focus again to maybe renew it window.addEventListener('focus', () => { + if (!this.authenticated) { + return + } + const expiresIn = (this.userInfo !== null ? this.userInfo.exp : 0) - +new Date() / 1000 // If the token expiry is negative, it is already expired and we have no choice but to redirect