Sfoglia il codice sorgente

refresh token in vue component every 5 minutes

pull/342/head
Guillaume Vincent 8 anni fa
parent
commit
166a1da17a
3 ha cambiato i file con 17 aggiunte e 14 eliminazioni
  1. +4
    -6
      src/components/PasswordGenerator.vue
  2. +1
    -5
      src/components/Passwords.vue
  3. +12
    -3
      src/store.js

+ 4
- 6
src/components/PasswordGenerator.vue Vedi File

@@ -142,17 +142,17 @@
numbers: true,
symbols: true,
length: 12,
counter: 1,
counter: 1
}
},
masterPassword: '',
encryptedLogin: '',
generatedPassword: '',
generatedPassword: ''
}
},
components: {
RemoveAutoComplete,
Fingerprint,
Fingerprint
},
watch: {
'password.site': function (siteId) {
@@ -211,9 +211,7 @@
}
},
created: function () {
if (this.isAuthenticated) {
this.$store.dispatch('loadPasswords');
}
this.$store.dispatch('loadPasswords');

var cb = new Clipboard('#copyPasswordButton');
cb.on('success', function (e) {


+ 1
- 5
src/components/Passwords.vue Vedi File

@@ -50,15 +50,11 @@
})
}
}),

methods: Object.assign(mapActions(['go']), {
setCurrentPasswordAndGoIndex(password){
this.$store.dispatch('setCurrentPassword', password);
this.go('index');
}
}),
created: function () {
this.$store.dispatch('loadPasswords');
}
})
}
</script>

+ 12
- 3
src/store.js Vedi File

@@ -59,9 +59,11 @@ const actions = {
commit('logout');
},
loadPasswords: ({commit}) => {
passwords.all().then(response => {
commit('loadPasswords', response.data.results);
});
if (auth.isAuthenticated()) {
passwords.all().then(response => {
commit('loadPasswords', response.data.results);
});
}
},
setCurrentPassword: ({commit}, password) => commit('setCurrentPassword', password),
};
@@ -85,3 +87,10 @@ export default function (config) {
});
}

const fiveMinutes = 1000 * 60 * 5;
if (auth.isAuthenticated()) {
auth.refreshToken();
setInterval(()=> {
auth.refreshToken();
}, fiveMinutes);
}

Caricamento…
Annulla
Salva