mirror of https://github.com/BTCPrivate/copay.git
fix broken encrypt in localstorage
This commit is contained in:
parent
9383d8e8d3
commit
ad40641646
|
@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
var _credentials, _firstpin;
|
||||
$scope.init = function() {
|
||||
$scope.isMobile = isMobile.any();
|
||||
$scope.attempt=0;
|
||||
$scope.attempt = 0;
|
||||
|
||||
// This is only for backwards compat, insight api should link to #!/confirmed directly
|
||||
if (getParam('confirmed')) {
|
||||
|
@ -72,7 +72,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
}
|
||||
$scope.open(credentials.email, credentials.password);
|
||||
});
|
||||
},100);
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.openWallets = function() {
|
||||
|
@ -98,7 +98,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
$rootScope.starting = null;
|
||||
$scope.openWallets();
|
||||
});
|
||||
},100);
|
||||
}, 100);
|
||||
};
|
||||
|
||||
$scope.openWithCredentials = function(form) {
|
||||
|
@ -128,7 +128,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
if ((err.toString() || '').match('PNOTFOUND')) {
|
||||
$scope.error = 'Invalid email or password';
|
||||
|
||||
if($scope.attempt++>1) {
|
||||
if ($scope.attempt++ > 1) {
|
||||
var storage = $scope.usingLocalStorage ? 'this device storage' : 'cloud storage';
|
||||
$scope.error = 'Invalid email or password. You are trying to sign in using ' + storage + '. Change it on settings is necessary.';
|
||||
};
|
||||
|
@ -144,9 +144,9 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
$scope.error = 'Unknown error';
|
||||
}
|
||||
$rootScope.starting = false;
|
||||
$timeout(function(){
|
||||
$timeout(function() {
|
||||
$rootScope.$digest();
|
||||
},1)
|
||||
}, 1)
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,9 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
|||
$scope.askForPin = 1;
|
||||
$rootScope.starting = false;
|
||||
$rootScope.hideNavigation = true;
|
||||
$timeout(function() {
|
||||
$rootScope.$digest();
|
||||
}, 1);
|
||||
return;
|
||||
}
|
||||
// no mobile
|
||||
|
|
|
@ -377,6 +377,7 @@ Identity.prototype._cleanUp = function() {
|
|||
* @desc Closes the wallet and disconnects all services
|
||||
*/
|
||||
Identity.prototype.close = function() {
|
||||
|
||||
this._cleanUp();
|
||||
this.emitAndKeepAlive('closed');
|
||||
};
|
||||
|
|
|
@ -10,6 +10,10 @@ function EncryptedInsightStorage(config) {
|
|||
inherits(EncryptedInsightStorage, InsightStorage);
|
||||
|
||||
|
||||
EncryptedInsightStorage.prototype._brokenDecryptUndef = function(body) {
|
||||
cryptoUtil.decrypt('undefined' + SEPARATOR + 'undefined', body);
|
||||
};
|
||||
|
||||
EncryptedInsightStorage.prototype._brokenDecrypt = function(body) {
|
||||
var key = cryptoUtil.kdf(this.password + this.email, 'mjuBtGybi/4=', 100);
|
||||
log.debug('Trying legacy decrypt')
|
||||
|
@ -31,6 +35,10 @@ EncryptedInsightStorage.prototype.getItem = function(name, callback) {
|
|||
decryptedJson = self._brokenDecrypt(body);
|
||||
}
|
||||
|
||||
if (!decryptedJson) {
|
||||
decryptedJson = self._brokenDecryptUndef(body);
|
||||
}
|
||||
|
||||
if (!decryptedJson) {
|
||||
log.debug('Could not decrypt value.');
|
||||
return callback('PNOTFOUND');
|
||||
|
|
|
@ -26,7 +26,8 @@ function LocalStorage(opts) {
|
|||
LocalStorage.prototype.init = function() {};
|
||||
|
||||
LocalStorage.prototype.setCredentials = function(email, password, opts) {
|
||||
// NOP
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
};
|
||||
|
||||
LocalStorage.prototype.getItem = function(k, cb) {
|
||||
|
|
Loading…
Reference in New Issue