Only check for token renew when the user is authenticated
This commit is contained in:
parent
1ee8efc90e
commit
c666f36cf4
1 changed files with 5 additions and 0 deletions
|
@ -56,6 +56,7 @@ export default {
|
||||||
background: 'background',
|
background: 'background',
|
||||||
menuActive: MENU_ACTIVE,
|
menuActive: MENU_ACTIVE,
|
||||||
userInfo: state => state.auth.info,
|
userInfo: state => state.auth.info,
|
||||||
|
authenticated: state => state.auth.authenticated,
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
doStuffAfterRoute() {
|
doStuffAfterRoute() {
|
||||||
|
@ -88,6 +89,10 @@ export default {
|
||||||
// Check if the token is still valid if the window gets focus again to maybe renew it
|
// Check if the token is still valid if the window gets focus again to maybe renew it
|
||||||
window.addEventListener('focus', () => {
|
window.addEventListener('focus', () => {
|
||||||
|
|
||||||
|
if (!this.authenticated) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const expiresIn = (this.userInfo !== null ? this.userInfo.exp : 0) - +new Date() / 1000
|
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
|
// If the token expiry is negative, it is already expired and we have no choice but to redirect
|
||||||
|
|
Loading…
Reference in a new issue