commit
f3d12f5a14
17 changed files with 141 additions and 91 deletions
|
|
@ -5,27 +5,38 @@ 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());
|
||||
$rootScope.$emit('Local/BackupDone');
|
||||
}
|
||||
if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic) {
|
||||
self.deleted = true;
|
||||
}
|
||||
|
||||
if (this.show)
|
||||
$rootScope.$emit('Local/BackupDone');
|
||||
self.toggle = function() {
|
||||
self.error = "";
|
||||
if (!self.credentialsEncrypted)
|
||||
self.show = !self.show;
|
||||
|
||||
$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 +44,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 +56,30 @@ 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
|
||||
return;
|
||||
}
|
||||
if (!self.show && self.credentialsEncrypted)
|
||||
self.show = !self.show;
|
||||
self.credentialsEncrypted = false;
|
||||
setWords(fc.getMnemonic());
|
||||
$rootScope.$emit('Local/BackupDone');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -1116,13 +1116,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.needsBackup = false;
|
||||
$log.debug('Backup done');
|
||||
storageService.setBackupFlag(self.walletId, function(err) {
|
||||
if (err) root.showErrorPopup(err);
|
||||
$log.debug('Backup done stored');
|
||||
});
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/DeviceError', function(event, err) {
|
||||
root.showErrorPopup(err);
|
||||
self.showErrorPopup(err, function() {
|
||||
if (self.isCordova && navigator && navigator.app) {
|
||||
navigator.app.exitApp();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/WalletImported', function(event, walletId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue