-
+
-
+
+
{{l.title}}
@@ -325,10 +348,18 @@
}
);
- // Schedule a token renew every minute
- setTimeout(() => {
- this.$store.dispatch('auth/renewToken')
- }, 1000 * 60)
+ // Try renewing the token every time vikunja is loaded initially
+ // (When opening the browser the focus event is not fired)
+ this.$store.dispatch('auth/renewToken')
+
+ // Check if the token is still valid if the window gets focus again to maybe renew it
+ window.addEventListener('focus', () => {
+ // Check if the token is valid for less than 60 hours and renew if thats the case
+ if (this.userInfo.exp - +new Date() / 1000 < 60 * 3600) {
+ this.$store.dispatch('auth/renewToken')
+ console.log('renewed token')
+ }
+ })
},
watch: {
// call the method again if the route changes