mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #370 from yemel/fix/bad-secret-handling
add validation to wallet secret
This commit is contained in:
commit
2c24591ee3
|
@ -496,3 +496,6 @@ a.loading {
|
|||
vertical-align:middle
|
||||
}
|
||||
|
||||
input.ng-invalid-wallet-secret {
|
||||
background: #FFB6C1;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
<div class="box-signin radius">
|
||||
<h3>Join a Wallet in Creation</h3>
|
||||
<form name="joinForm" ng-submit="join(joinForm)" novalidate>
|
||||
<input type="text" class="form-control" placeholder="Paste wallet secret here" name="connectionId" ng-model="connectionId" required>
|
||||
<input type="text" class="form-control" placeholder="Paste wallet secret here" name="connectionId" ng-model="connectionId" wallet-secret required>
|
||||
<input type="password" class="form-control" placeholder="Choose your password" name="joinPassword" ng-model="joinPassword" required>
|
||||
<input type="text" class="form-control" placeholder="Your name (optional)" name="nickname" ng-model="nickname">
|
||||
<button type="submit" class="button primary radius" ng-disabled="joinForm.$invalid || loading" loading="Joining">Join</button>
|
||||
|
|
|
@ -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…
Reference in New Issue