add validation to wallet secret
This commit is contained in:
parent
eedfdcfaa1
commit
9d5f2ddf16
4 changed files with 29 additions and 7 deletions
|
|
@ -64,6 +64,21 @@ angular.module('copay.directives')
|
|||
};
|
||||
}
|
||||
])
|
||||
.directive('walletSecret', ['walletFactory',
|
||||
function(walletFactory) {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, elem, attrs, ctrl) {
|
||||
var validator = function(value) {
|
||||
ctrl.$setValidity('walletSecret', Boolean(walletFactory.decodeSecret(value)));
|
||||
return value;
|
||||
};
|
||||
|
||||
ctrl.$parsers.unshift(validator);
|
||||
}
|
||||
};
|
||||
}
|
||||
])
|
||||
.directive('loading', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
|
|
|
|||
|
|
@ -162,16 +162,20 @@ WalletFactory.prototype.remove = function(walletId) {
|
|||
this.log('TODO: remove wallet contents');
|
||||
};
|
||||
|
||||
WalletFactory.prototype.decodeSecret = function(secret) {
|
||||
try {
|
||||
return Wallet.decodeSecret(secret);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WalletFactory.prototype.joinCreateSession = function(secret, nickname, passphrase, cb) {
|
||||
var self = this;
|
||||
|
||||
var s;
|
||||
try {
|
||||
s=Wallet.decodeSecret(secret);
|
||||
} catch (e) {
|
||||
return cb('badSecret');
|
||||
}
|
||||
var s = self.decodeSecret(secret);
|
||||
if (!s) return cb('badSecret');
|
||||
|
||||
//Create our PrivateK
|
||||
var privateKey = new PrivateKey({ networkName: this.networkName });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue