fixes credentials storage
This commit is contained in:
parent
b4feae31e4
commit
7111bdf7f2
4 changed files with 17 additions and 10 deletions
|
|
@ -48,7 +48,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
||||||
|
|
||||||
fc.setPrivateKeyEncryption(password);
|
fc.setPrivateKeyEncryption(password);
|
||||||
fc.lock();
|
fc.lock();
|
||||||
profileService.updateCredentials(fc.export(), function() {
|
profileService.updateCredentials(JSON.parse(fc.export()), function() {
|
||||||
$log.debug('Wallet encrypted');
|
$log.debug('Wallet encrypted');
|
||||||
return cb();
|
return cb();
|
||||||
});
|
});
|
||||||
|
|
@ -62,7 +62,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return cb(e);
|
return cb(e);
|
||||||
}
|
}
|
||||||
profileService.updateCredentials(fc.export(), function() {
|
profileService.updateCredentials(JSON.parse(fc.export()), function() {
|
||||||
$log.debug('Wallet encryption disabled');
|
$log.debug('Wallet encryption disabled');
|
||||||
return cb();
|
return cb();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,9 @@ Profile.prototype.setChecked = function(ua, walletId) {
|
||||||
|
|
||||||
|
|
||||||
Profile.prototype.addWallet = function(credentials) {
|
Profile.prototype.addWallet = function(credentials) {
|
||||||
|
if (!credentials.walletId)
|
||||||
|
throw 'credentials must have .walletId';
|
||||||
|
|
||||||
if (this.hasWallet(credentials.walletId))
|
if (this.hasWallet(credentials.walletId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -83,14 +86,20 @@ Profile.prototype.addWallet = function(credentials) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Profile.prototype.updateWallet = function(credentials) {
|
Profile.prototype.updateWallet = function(credentials) {
|
||||||
|
if (!credentials.walletId)
|
||||||
|
throw 'credentials must have .walletId';
|
||||||
|
|
||||||
if (!this.hasWallet(credentials.walletId))
|
if (!this.hasWallet(credentials.walletId))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.credentials = this.credentials.filter(function(c) {
|
this.credentials = this.credentials.map(function(c) {
|
||||||
return c.walletId != walletId;
|
if(c.walletId != credentials.walletId ) {
|
||||||
|
return c;
|
||||||
|
} else {
|
||||||
|
return credentials
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addWallet(credentials);
|
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -669,7 +669,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.setDisclaimerAccepted = function(cb) {
|
root.setDisclaimerAccepted = function(cb) {
|
||||||
root.profile.disclaimerAccepted = true;
|
root.profile.disclaimerAccepted = true;
|
||||||
storageService.storeProfileThrottled(root.profile, function(err) {
|
storageService.storeProfile(root.profile, function(err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -691,8 +691,8 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.updateCredentials = function(credentials, cb) {
|
root.updateCredentials = function(credentials, cb) {
|
||||||
root.profile.updateWallet(credentials);
|
var t = root.profile.updateWallet(credentials);
|
||||||
storageService.storeProfileThrottled(root.profile, cb);
|
storageService.storeProfile(root.profile, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getClients = function() {
|
root.getClients = function() {
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,6 @@ angular.module('copayApp.services')
|
||||||
storage.set('profile', profile.toObj(), cb);
|
storage.set('profile', profile.toObj(), cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.storeProfileThrottled = lodash.throttle(root.storeProfile, 5000);
|
|
||||||
|
|
||||||
root.getProfile = function(cb) {
|
root.getProfile = function(cb) {
|
||||||
storage.get('profile', function(err, str) {
|
storage.get('profile', function(err, str) {
|
||||||
if (err || !str)
|
if (err || !str)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue