From 9a35c741a2ff41e25b0ff7f63c93bc6af10207e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 28 Oct 2015 15:57:08 -0300 Subject: [PATCH 1/3] password required in backup page --- public/views/backup.html | 27 +++++++------- src/js/controllers/backup.js | 70 ++++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/public/views/backup.html b/public/views/backup.html index f3d85f9a8..25a2c3ce5 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -8,7 +8,6 @@

-
{{wordsC.error|translate}} @@ -17,7 +16,7 @@ -
+
@@ -33,11 +32,11 @@ To restore this {{index.m}}-{{index.n}} shared wallet you will need : -
    -
  1. Your wallet seed and access to the server that coordinated the initial wallet creation. You still need {{index.m}} keys to spend.
  2. -
  3. OR the wallet seed of all copayers in the wallet
  4. -
  5. OR 1 wallet export file and the remaining quorum of wallet seeds (e.g. in a 3-5 wallet: 1 wallet export file + 2 wallet seeds of any of the other copayers).
  6. -
+
    +
  1. Your wallet seed and access to the server that coordinated the initial wallet creation. You still need {{index.m}} keys to spend.
  2. +
  3. OR the wallet seed of all copayers in the wallet
  4. +
  5. OR 1 wallet export file and the remaining quorum of wallet seeds (e.g. in a 3-5 wallet: 1 wallet export file + 2 wallet seeds of any of the other copayers).
  6. +
@@ -46,22 +45,22 @@ To restore this {{index.m}}-{{index.n}} shared wallet you will need : -
    -
  1. Your wallet seed and access to the server that coordinated the initial wallet creation. You still need {{index.m}} keys to spend.
  2. -
  3. OR the wallet seeds of all copayers in the wallet
  4. -
+
    +
  1. Your wallet seed and access to the server that coordinated the initial wallet creation. You still need {{index.m}} keys to spend.
  2. +
  3. OR the wallet seeds of all copayers in the wallet
  4. +
- -
+ +
Wallet seed not available. You can still export it from Advanced > Export.
-
+
diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index f99f1a946..77a83c320 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -5,27 +5,37 @@ angular.module('copayApp.controllers').controller('wordsController', var msg = gettext('Are you sure you want to delete the backup words?'); var successMsg = gettext('Backup words deleted'); - this.show = false; - var self = this; + self.show = false; + var fc = profileService.focusedClient; - this.toggle = function() { - this.show = !this.show; + if (fc.isPrivKeyEncrypted()) self.credentialsEncrypted = true; + else setWords(fc.getMnemonic()); - if (this.show) + if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic) { + self.deleted = true; + } + + self.toggle = function() { + self.error = ""; + self.show = !self.show; + if (self.show) $rootScope.$emit('Local/BackupDone'); - $timeout(function(){ + if (self.credentialsEncrypted) + self.passwordRequest(); + + $timeout(function() { $scope.$apply(); }, 1); }; - this.delete = function() { - var fc = profileService.focusedClient; + self.delete = function() { confirmDialog.show(msg, function(ok) { if (ok) { fc.clearMnemonic(); profileService.updateCredentialsFC(function() { + self.deleted = true; notification.success(successMsg); go.walletHome(); }); @@ -33,12 +43,10 @@ angular.module('copayApp.controllers').controller('wordsController', }); }; - $scope.$on('$destroy', function() { profileService.lockFC(); }); - function setWords(words) { if (words) { self.mnemonicWords = words.split(/[\u3000\s]+/); @@ -47,26 +55,28 @@ angular.module('copayApp.controllers').controller('wordsController', } }; - var fc = profileService.focusedClient; - try { - setWords(fc.getMnemonic()); - } catch (e) { - if (e.message && e.message.match(/encrypted/) && fc.isPrivKeyEncrypted()) { - self.credentialsEncrypted = true; + self.passwordRequest = function() { + try { + setWords(fc.getMnemonic()); + } catch (e) { + if (e.message && e.message.match(/encrypted/) && fc.isPrivKeyEncrypted()) { + self.credentialsEncrypted = true; - $timeout(function(){ - $scope.$apply(); - }, 1); + $timeout(function() { + $scope.$apply(); + }, 1); - profileService.unlockFC(function(err) { - if (err) { - self.error = bwsError.msg(err, gettext('Could not decrypt')); - $log.warn('Error decrypting credentials:',self.error); //TODO - return; - } - self.credentialsEncrypted = false; - setWords(fc.getMnemonic()); - }); - } + profileService.unlockFC(function(err) { + if (err) { + self.error = bwsError.msg(err, gettext('Could not decrypt')); + $log.warn('Error decrypting credentials:', self.error); //TODO + self.show = !self.show; + return; + } + self.credentialsEncrypted = false; + setWords(fc.getMnemonic()); + }); + } + } } - }); + }); \ No newline at end of file From d2649773a40cc699be03b4ebcca79e644c40ef49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Wed, 28 Oct 2015 16:29:48 -0300 Subject: [PATCH 2/3] fix showing words --- src/js/controllers/backup.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index 77a83c320..d2cf89e3a 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -18,7 +18,9 @@ angular.module('copayApp.controllers').controller('wordsController', self.toggle = function() { self.error = ""; - self.show = !self.show; + if (!self.credentialsEncrypted) + self.show = !self.show; + if (self.show) $rootScope.$emit('Local/BackupDone'); @@ -70,9 +72,10 @@ angular.module('copayApp.controllers').controller('wordsController', if (err) { self.error = bwsError.msg(err, gettext('Could not decrypt')); $log.warn('Error decrypting credentials:', self.error); //TODO - self.show = !self.show; return; } + if (!self.show && self.credentialsEncrypted) + self.show = !self.show; self.credentialsEncrypted = false; setWords(fc.getMnemonic()); }); From ba17f201d1f2e56bf1347bd5fad369dd770e0d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 29 Oct 2015 14:45:26 -0300 Subject: [PATCH 3/3] fix BackupDone --- src/js/controllers/backup.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index d2cf89e3a..25a92733c 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -10,8 +10,10 @@ angular.module('copayApp.controllers').controller('wordsController', var fc = profileService.focusedClient; if (fc.isPrivKeyEncrypted()) self.credentialsEncrypted = true; - else setWords(fc.getMnemonic()); - + else { + setWords(fc.getMnemonic()); + $rootScope.$emit('Local/BackupDone'); + } if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic) { self.deleted = true; } @@ -21,9 +23,6 @@ angular.module('copayApp.controllers').controller('wordsController', if (!self.credentialsEncrypted) self.show = !self.show; - if (self.show) - $rootScope.$emit('Local/BackupDone'); - if (self.credentialsEncrypted) self.passwordRequest(); @@ -78,6 +77,7 @@ angular.module('copayApp.controllers').controller('wordsController', self.show = !self.show; self.credentialsEncrypted = false; setWords(fc.getMnemonic()); + $rootScope.$emit('Local/BackupDone'); }); } }