Fix signing when put a wrong password. Fixes #297

This commit is contained in:
Gustavo Cortez 2014-05-06 17:57:16 -03:00
parent aa0ed193fd
commit ab9be793cb
3 changed files with 13 additions and 4 deletions

View File

@ -21,6 +21,11 @@ angular.module('copay.signin').controller('SigninController',
var passphrase = Passphrase.getBase64($scope.openPassword);
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);
}
};

View File

@ -138,8 +138,11 @@ WalletFactory.prototype.open = function(walletId, opts) {
opts.verbose = this.verbose;
this.storage._setPassphrase(opts.passphrase);
var w = this.read(walletId) || this.create(opts);
w.store();
var w = this.read(walletId);
if (w) {
w.store();
}
return w;
};
@ -186,7 +189,8 @@ WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphras
data.opts.privateKey = privateKey;
data.opts.nickname = nickname;
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;
return cb(null, w);
}

View File

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