Merge pull request #304 from cmgustavo/bug/open-wallet

Sign-in when put a wrong password. Fixes #297
This commit is contained in:
Matias Alejo Garcia 2014-05-06 19:22:40 -03:00
commit fa8c2eada5
3 changed files with 14 additions and 5 deletions

View file

@ -23,11 +23,16 @@ angular.module('copay.signin').controller('SigninController',
$rootScope.flashMessage = { message: 'Please, enter required fields', type: 'error'}; $rootScope.flashMessage = { message: 'Please, enter required fields', type: 'error'};
return; return;
} }
$scope.loading = true; $scope.loading = true;
var password = form.openPassword.$modelValue; var password = form.openPassword.$modelValue;
var passphrase = Passphrase.getBase64(password); var passphrase = Passphrase.getBase64(password);
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase}); var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
if (!w) {
$scope.loading = false;
$rootScope.flashMessage = { message: 'Bad password or connection error', type: 'error'};
return;
}
controllerUtils.startNetwork(w); controllerUtils.startNetwork(w);
}; };

View file

@ -140,8 +140,11 @@ WalletFactory.prototype.open = function(walletId, opts) {
opts.verbose = this.verbose; opts.verbose = this.verbose;
this.storage._setPassphrase(opts.passphrase); this.storage._setPassphrase(opts.passphrase);
var w = this.read(walletId) || this.create(opts); var w = this.read(walletId);
w.store();
if (w) {
w.store();
}
return w; return w;
}; };
@ -188,7 +191,8 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphras
data.opts.privateKey = privateKey; data.opts.privateKey = privateKey;
data.opts.nickname = nickname; data.opts.nickname = nickname;
data.opts.passphrase = passphrase; data.opts.passphrase = passphrase;
var w = self.open(data.walletId, data.opts); data.opts.id = data.walletId;
var w = self.create(data.opts);
w.firstCopayerId = s.pubKey; w.firstCopayerId = s.pubKey;
return cb(null, w); return cb(null, w);
} }

View file

@ -54,7 +54,7 @@ Storage.prototype._read = function(k) {
} }
} catch (e) { } catch (e) {
console.log('Error while decrypting: '+e); console.log('Error while decrypting: '+e);
throw e; return null;
}; };
return ret; return ret;