Browse Source

refresh token in vue component every 5 minutes

pull/342/head
Guillaume Vincent 8 years ago
parent
commit
166a1da17a
3 changed files with 17 additions and 14 deletions
  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 View File

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


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


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

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

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

+ 12
- 3
src/store.js View File

@@ -59,9 +59,11 @@ const actions = {
commit('logout'); commit('logout');
}, },
loadPasswords: ({commit}) => { 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), 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);
}

Loading…
Cancel
Save