From c37c3e7576488ed5aa39540791ea753150bb879a Mon Sep 17 00:00:00 2001 From: Guillaume Vincent Date: Fri, 14 Oct 2016 15:12:03 +0200 Subject: [PATCH] fix #19 credentials are not reset after some time --- src/views/PasswordGenerator.vue | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/views/PasswordGenerator.vue b/src/views/PasswordGenerator.vue index e19c674..3376dab 100644 --- a/src/views/PasswordGenerator.vue +++ b/src/views/PasswordGenerator.vue @@ -106,6 +106,7 @@ @@ -183,8 +184,7 @@ this.generatedPassword = ''; return; } - const password = new Password(this.password); - return lesspass.renderPassword(this.encryptedLogin, this.password.site, password.options); + return this.generatePassword(); } }, preFetch: fetchPasswords, @@ -198,9 +198,7 @@ } var clipboard = new Clipboard('#copyPasswordButton'); - var vm = this; clipboard.on('success', event => { - vm.$store.dispatch('PASSWORD_GENERATED'); if (event.text) { showTooltip(event.trigger, 'copied !'); } @@ -210,7 +208,8 @@ return { masterPassword: '', encryptedLogin: '', - generatedPassword: '' + generatedPassword: '', + cleanTimeout: null } }, watch: { @@ -239,6 +238,9 @@ 'masterPassword': function () { this.encryptedLogin = ''; this.encryptLogin(); + }, + 'generatedPassword': function () { + this.cleanFormInSeconds(30); } }, methods: { @@ -255,6 +257,20 @@ } else { this.$refs.masterPassword.type = 'password'; } + }, + generatePassword(){ + const password = new Password(this.password); + const generatedPassword = lesspass.renderPassword(this.encryptedLogin, this.password.site, password.options); + this.$store.dispatch('PASSWORD_GENERATED'); + return generatedPassword; + }, + cleanFormInSeconds(seconds){ + clearTimeout(this.cleanTimeout); + this.cleanTimeout = setTimeout(() => { + this.masterPassword = ''; + this.encryptedLogin = ''; + this.generatedPassword = ''; + }, 1000 * seconds); } } }