fix broken encrypt in localstorage

This commit is contained in:
Matias Alejo Garcia 2014-12-13 19:38:39 -03:00
commit ad40641646
4 changed files with 23 additions and 11 deletions

View file

@ -164,7 +164,9 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
$scope.askForPin = 1; $scope.askForPin = 1;
$rootScope.starting = false; $rootScope.starting = false;
$rootScope.hideNavigation = true; $rootScope.hideNavigation = true;
$timeout(function() {
$rootScope.$digest(); $rootScope.$digest();
}, 1);
return; return;
} }
// no mobile // no mobile

View file

@ -377,6 +377,7 @@ Identity.prototype._cleanUp = function() {
* @desc Closes the wallet and disconnects all services * @desc Closes the wallet and disconnects all services
*/ */
Identity.prototype.close = function() { Identity.prototype.close = function() {
this._cleanUp(); this._cleanUp();
this.emitAndKeepAlive('closed'); this.emitAndKeepAlive('closed');
}; };

View file

@ -10,6 +10,10 @@ function EncryptedInsightStorage(config) {
inherits(EncryptedInsightStorage, InsightStorage); inherits(EncryptedInsightStorage, InsightStorage);
EncryptedInsightStorage.prototype._brokenDecryptUndef = function(body) {
cryptoUtil.decrypt('undefined' + SEPARATOR + 'undefined', body);
};
EncryptedInsightStorage.prototype._brokenDecrypt = function(body) { EncryptedInsightStorage.prototype._brokenDecrypt = function(body) {
var key = cryptoUtil.kdf(this.password + this.email, 'mjuBtGybi/4=', 100); var key = cryptoUtil.kdf(this.password + this.email, 'mjuBtGybi/4=', 100);
log.debug('Trying legacy decrypt') log.debug('Trying legacy decrypt')
@ -31,6 +35,10 @@ EncryptedInsightStorage.prototype.getItem = function(name, callback) {
decryptedJson = self._brokenDecrypt(body); decryptedJson = self._brokenDecrypt(body);
} }
if (!decryptedJson) {
decryptedJson = self._brokenDecryptUndef(body);
}
if (!decryptedJson) { if (!decryptedJson) {
log.debug('Could not decrypt value.'); log.debug('Could not decrypt value.');
return callback('PNOTFOUND'); return callback('PNOTFOUND');

View file

@ -26,7 +26,8 @@ function LocalStorage(opts) {
LocalStorage.prototype.init = function() {}; LocalStorage.prototype.init = function() {};
LocalStorage.prototype.setCredentials = function(email, password, opts) { LocalStorage.prototype.setCredentials = function(email, password, opts) {
// NOP this.email = email;
this.password = password;
}; };
LocalStorage.prototype.getItem = function(k, cb) { LocalStorage.prototype.getItem = function(k, cb) {