mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #512 from maraoz/UI/separate-errors
UI: separate login errors
This commit is contained in:
commit
6d922b7780
|
@ -182,7 +182,7 @@
|
||||||
<div class="signin" ng-controller="SigninController">
|
<div class="signin" ng-controller="SigninController">
|
||||||
<div data-alert class="alert-box info radius" ng-show="loading && !failure">
|
<div data-alert class="alert-box info radius" ng-show="loading && !failure">
|
||||||
<i class="size-21 fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="size-21 fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
Authenticating and Looking for peers...
|
Authenticating and looking for peers...
|
||||||
</div>
|
</div>
|
||||||
<div class="alert-box error radius" ng-show="failure">
|
<div class="alert-box error radius" ng-show="failure">
|
||||||
Oops, we had an error! Looks like you are already connected to this wallet,
|
Oops, we had an error! Looks like you are already connected to this wallet,
|
||||||
|
@ -309,7 +309,7 @@
|
||||||
<div class="small-12 medium-6 medium-centered large-6 large-centered columns m30v">
|
<div class="small-12 medium-6 medium-centered large-6 large-centered columns m30v">
|
||||||
<h6>Your Wallet Password<small>(doesn't need to be shared) Required</small></h6>
|
<h6>Your Wallet Password<small>(doesn't need to be shared) Required</small></h6>
|
||||||
<input type="password" placeholder="Choose your password" class="form-control"
|
<input type="password" placeholder="Choose your password" class="form-control"
|
||||||
ng-model="walletPassword" check-strength="passwordStrength" tooltip="Password strength: {{passwordStrength}}" tooltip-trigger="focus" required>
|
ng-model="walletPassword" check-strength="passwordStrength" tooltip-trigger="focus" required>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-6 medium-centered large-6 large-centered columns m30v">
|
<div class="small-12 medium-6 medium-centered large-6 large-centered columns m30v">
|
||||||
<h6>Wallet name <small>Optional</small></h6>
|
<h6>Wallet name <small>Optional</small></h6>
|
||||||
|
|
|
@ -6,7 +6,15 @@ angular.module('copay.import').controller('ImportController',
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
var _importBackup = function(encryptedObj) {
|
var _importBackup = function(encryptedObj) {
|
||||||
Passphrase.getBase64Async($scope.password, function(passphrase){
|
Passphrase.getBase64Async($scope.password, function(passphrase){
|
||||||
$rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase);
|
var w = walletFactory.fromEncryptedObj(encryptedObj, passphrase);
|
||||||
|
if (!w) {
|
||||||
|
$scope.loading = false;
|
||||||
|
$rootScope.$flashMessage = { message: 'Wrong password', type: 'error'};
|
||||||
|
$rootScope.$digest();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$rootScope.wallet = w;
|
||||||
|
|
||||||
controllerUtils.startNetwork($rootScope.wallet);
|
controllerUtils.startNetwork($rootScope.wallet);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -23,6 +31,7 @@ angular.module('copay.import').controller('ImportController',
|
||||||
|
|
||||||
$scope.import = function(form) {
|
$scope.import = function(form) {
|
||||||
if (form.$invalid) {
|
if (form.$invalid) {
|
||||||
|
$scope.loading = false;
|
||||||
$rootScope.$flashMessage = { message: 'There is an error in the form. Please, try again', type: 'error'};
|
$rootScope.$flashMessage = { message: 'There is an error in the form. Please, try again', type: 'error'};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +41,7 @@ angular.module('copay.import').controller('ImportController',
|
||||||
var password = form.password.$modelValue;
|
var password = form.password.$modelValue;
|
||||||
|
|
||||||
if (!backupFile && !backupText) {
|
if (!backupFile && !backupText) {
|
||||||
|
$scope.loading = false;
|
||||||
$rootScope.$flashMessage = { message: 'Please, select your backup file or paste the text', type: 'error'};
|
$rootScope.$flashMessage = { message: 'Please, select your backup file or paste the text', type: 'error'};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,17 +27,15 @@ angular.module('copay.signin').controller('SigninController',
|
||||||
|
|
||||||
console.log('## Obtaining passphrase...');
|
console.log('## Obtaining passphrase...');
|
||||||
Passphrase.getBase64Async(password, function(passphrase){
|
Passphrase.getBase64Async(password, function(passphrase){
|
||||||
console.log('## Done.');
|
console.log('## Passphrase obtained');
|
||||||
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
|
var w = walletFactory.open($scope.selectedWalletId, { passphrase: passphrase});
|
||||||
if (!w) {
|
if (!w) {
|
||||||
$scope.loading = $scope.failure = false;
|
$scope.loading = $scope.failure = false;
|
||||||
$rootScope.$flashMessage = { message: 'Bad password or connection error', type: 'error'};
|
$rootScope.$flashMessage = { message: 'Wrong password', type: 'error'};
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('[signin.js.49]'); //TODO
|
|
||||||
installStartupHandlers(w);
|
installStartupHandlers(w);
|
||||||
console.log('[signin.js.52]'); //TODO
|
|
||||||
controllerUtils.startNetwork(w);
|
controllerUtils.startNetwork(w);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,9 +63,7 @@ Wallet.prototype.seedCopayer = function(pubKey) {
|
||||||
|
|
||||||
Wallet.prototype.connectToAll = function() {
|
Wallet.prototype.connectToAll = function() {
|
||||||
|
|
||||||
console.log('[Wallet.js.57]'); //TODO
|
|
||||||
var all = this.publicKeyRing.getAllCopayerIds();
|
var all = this.publicKeyRing.getAllCopayerIds();
|
||||||
|
|
||||||
console.log('[Wallet.js.58] connecting'); //TODO
|
console.log('[Wallet.js.58] connecting'); //TODO
|
||||||
this.network.connectToCopayers(all);
|
this.network.connectToCopayers(all);
|
||||||
if (this.seededCopayerId) {
|
if (this.seededCopayerId) {
|
||||||
|
@ -224,8 +222,8 @@ Wallet.prototype.netStart = function() {
|
||||||
self.log('[Wallet.js.132:openError:] GOT openError'); //TODO
|
self.log('[Wallet.js.132:openError:] GOT openError'); //TODO
|
||||||
self.emit('openError');
|
self.emit('openError');
|
||||||
});
|
});
|
||||||
net.on('error', function(){
|
net.on('error', function() {
|
||||||
self.emit('connectionError'); // Bubble the error
|
self.emit('connectionError');
|
||||||
});
|
});
|
||||||
net.on('close', function() {
|
net.on('close', function() {
|
||||||
self.emit('close');
|
self.emit('close');
|
||||||
|
|
|
@ -39,14 +39,11 @@ WalletFactory.prototype.log = function(){
|
||||||
WalletFactory.prototype._checkRead = function(walletId) {
|
WalletFactory.prototype._checkRead = function(walletId) {
|
||||||
var s = this.storage;
|
var s = this.storage;
|
||||||
var ret =
|
var ret =
|
||||||
(
|
|
||||||
s.get(walletId, 'publicKeyRing') &&
|
s.get(walletId, 'publicKeyRing') &&
|
||||||
s.get(walletId, 'txProposals') &&
|
s.get(walletId, 'txProposals') &&
|
||||||
s.get(walletId, 'opts') &&
|
s.get(walletId, 'opts') &&
|
||||||
s.get(walletId, 'privateKey')
|
s.get(walletId, 'privateKey');
|
||||||
)?true:false;
|
return !!ret;
|
||||||
;
|
|
||||||
return ret?true:false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletFactory.prototype.fromObj = function(obj) {
|
WalletFactory.prototype.fromObj = function(obj) {
|
||||||
|
@ -60,8 +57,9 @@ WalletFactory.prototype.fromObj = function(obj) {
|
||||||
WalletFactory.prototype.fromEncryptedObj = function(base64, password) {
|
WalletFactory.prototype.fromEncryptedObj = function(base64, password) {
|
||||||
this.storage._setPassphrase(password);
|
this.storage._setPassphrase(password);
|
||||||
var walletObj = this.storage.import(base64);
|
var walletObj = this.storage.import(base64);
|
||||||
var w= this.fromObj(walletObj);
|
if (!walletObj) return false;
|
||||||
w.store();
|
var w = this.fromObj(walletObj);
|
||||||
|
if (!w) return false;
|
||||||
return w;
|
return w;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -149,7 +147,6 @@ WalletFactory.prototype.open = function(walletId, opts) {
|
||||||
|
|
||||||
var w = this.read(walletId);
|
var w = this.read(walletId);
|
||||||
|
|
||||||
|
|
||||||
if (w) {
|
if (w) {
|
||||||
this._checkVersion(w.version);
|
this._checkVersion(w.version);
|
||||||
w.store();
|
w.store();
|
||||||
|
|
|
@ -269,7 +269,6 @@ Network.prototype._setupPeerHandlers = function(openCallback) {
|
||||||
self._checkAnyPeer();
|
self._checkAnyPeer();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
p.on('connection', function(dataConn) {
|
p.on('connection', function(dataConn) {
|
||||||
console.log('### NEW INBOUND CONNECTION %d/%d', self.connectedPeers.length, self.maxPeers);
|
console.log('### NEW INBOUND CONNECTION %d/%d', self.connectedPeers.length, self.maxPeers);
|
||||||
if (self.connectedPeers.length >= self.maxPeers) {
|
if (self.connectedPeers.length >= self.maxPeers) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
var imports = require('soop').imports();
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
var id = 0;
|
var id = 0;
|
||||||
|
|
||||||
function Storage(opts) {
|
function Storage(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
|
@ -33,12 +34,16 @@ Storage.prototype._encryptObj = function(obj) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Storage.prototype._decrypt = function(base64) {
|
Storage.prototype._decrypt = function(base64) {
|
||||||
var decryptedStr=null;
|
var decryptedStr = null;
|
||||||
var decrypted = CryptoJS.AES.decrypt(base64, this._getPassphrase());
|
try {
|
||||||
|
var decrypted = CryptoJS.AES.decrypt(base64, this._getPassphrase());
|
||||||
if (decrypted)
|
|
||||||
decryptedStr = decrypted.toString(CryptoJS.enc.Utf8);
|
|
||||||
|
|
||||||
|
if (decrypted)
|
||||||
|
decryptedStr = decrypted.toString(CryptoJS.enc.Utf8);
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Error while decrypting ' + base64);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return decryptedStr;
|
return decryptedStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,22 +54,16 @@ Storage.prototype._decryptObj = function(base64) {
|
||||||
|
|
||||||
Storage.prototype._read = function(k) {
|
Storage.prototype._read = function(k) {
|
||||||
var ret;
|
var ret;
|
||||||
try {
|
ret = localStorage.getItem(k);
|
||||||
ret = localStorage.getItem(k);
|
if (!ret) return null;
|
||||||
if (ret){
|
ret = this._decrypt(ret);
|
||||||
ret = this._decrypt(ret);
|
if (!ret) return null;
|
||||||
ret = ret.toString(CryptoJS.enc.Utf8);
|
ret = ret.toString(CryptoJS.enc.Utf8);
|
||||||
ret = JSON.parse(ret);
|
ret = JSON.parse(ret);
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error while decrypting: '+e);
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
Storage.prototype._write = function(k,v) {
|
Storage.prototype._write = function(k, v) {
|
||||||
v = JSON.stringify(v);
|
v = JSON.stringify(v);
|
||||||
v = this._encrypt(v);
|
v = this._encrypt(v);
|
||||||
|
|
||||||
|
@ -78,7 +77,7 @@ Storage.prototype.getGlobal = function(k) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// set value for key
|
// set value for key
|
||||||
Storage.prototype.setGlobal = function(k,v) {
|
Storage.prototype.setGlobal = function(k, v) {
|
||||||
localStorage.setItem(k, JSON.stringify(v));
|
localStorage.setItem(k, JSON.stringify(v));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,46 +91,45 @@ Storage.prototype._key = function(walletId, k) {
|
||||||
};
|
};
|
||||||
// get value by key
|
// get value by key
|
||||||
Storage.prototype.get = function(walletId, k) {
|
Storage.prototype.get = function(walletId, k) {
|
||||||
var ret = this._read(this._key(walletId,k));
|
var ret = this._read(this._key(walletId, k));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
// set value for key
|
// set value for key
|
||||||
Storage.prototype.set = function(walletId, k,v) {
|
Storage.prototype.set = function(walletId, k, v) {
|
||||||
this._write(this._key(walletId,k), v);
|
this._write(this._key(walletId, k), v);
|
||||||
};
|
};
|
||||||
|
|
||||||
// remove value for key
|
// remove value for key
|
||||||
Storage.prototype.remove = function(walletId, k) {
|
Storage.prototype.remove = function(walletId, k) {
|
||||||
this.removeGlobal(this._key(walletId,k));
|
this.removeGlobal(this._key(walletId, k));
|
||||||
};
|
};
|
||||||
|
|
||||||
Storage.prototype.setName = function(walletId, name) {
|
Storage.prototype.setName = function(walletId, name) {
|
||||||
this.setGlobal('nameFor::'+walletId, name);
|
this.setGlobal('nameFor::' + walletId, name);
|
||||||
};
|
};
|
||||||
|
|
||||||
Storage.prototype.getName = function(walletId) {
|
Storage.prototype.getName = function(walletId) {
|
||||||
return this.getGlobal('nameFor::'+walletId);
|
return this.getGlobal('nameFor::' + walletId);
|
||||||
};
|
};
|
||||||
|
|
||||||
Storage.prototype.getWalletIds = function() {
|
Storage.prototype.getWalletIds = function() {
|
||||||
var walletIds = [];
|
var walletIds = [];
|
||||||
var uniq = {};
|
var uniq = {};
|
||||||
for (var i = 0; i < localStorage.length; i++) {
|
for (var i = 0; i < localStorage.length; i++) {
|
||||||
var key = localStorage.key(i);
|
var key = localStorage.key(i);
|
||||||
var split = key.split('::');
|
var split = key.split('::');
|
||||||
if (split.length == 2) {
|
if (split.length == 2) {
|
||||||
var walletId = split[0];
|
var walletId = split[0];
|
||||||
|
|
||||||
if (walletId === 'nameFor') continue;
|
if (walletId === 'nameFor') continue;
|
||||||
|
|
||||||
if (typeof uniq[walletId] === 'undefined' ) {
|
if (typeof uniq[walletId] === 'undefined') {
|
||||||
walletIds.push(walletId);
|
walletIds.push(walletId);
|
||||||
uniq[walletId] = 1;
|
uniq[walletId] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return walletIds;
|
return walletIds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,9 +138,9 @@ Storage.prototype.getWallets = function() {
|
||||||
var uniq = {};
|
var uniq = {};
|
||||||
var ids = this.getWalletIds();
|
var ids = this.getWalletIds();
|
||||||
|
|
||||||
for (var i in ids){
|
for (var i in ids) {
|
||||||
wallets.push({
|
wallets.push({
|
||||||
id:ids[i],
|
id: ids[i],
|
||||||
name: this.getName(ids[i]),
|
name: this.getName(ids[i]),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,35 +62,29 @@ angular.module('copay.controllerUtils')
|
||||||
$rootScope.wallet = w;
|
$rootScope.wallet = w;
|
||||||
$location.path('addresses');
|
$location.path('addresses');
|
||||||
video.setOwnPeer(myPeerID, w, handlePeerVideo);
|
video.setOwnPeer(myPeerID, w, handlePeerVideo);
|
||||||
console.log('# Done ready handler');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
w.on('publicKeyRingUpdated', function(dontDigest) {
|
w.on('publicKeyRingUpdated', function(dontDigest) {
|
||||||
console.log('[start publicKeyRing handler]'); //TODO
|
|
||||||
root.setSocketHandlers();
|
root.setSocketHandlers();
|
||||||
root.updateAddressList();
|
root.updateAddressList();
|
||||||
if (!dontDigest) {
|
if (!dontDigest) {
|
||||||
console.log('[pkr digest]');
|
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
console.log('[done digest]');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
w.on('txProposalsUpdated', function(dontDigest) {
|
w.on('txProposalsUpdated', function(dontDigest) {
|
||||||
root.updateTxs({onlyPending:true});
|
root.updateTxs({onlyPending:true});
|
||||||
root.updateBalance(function(){
|
root.updateBalance(function(){
|
||||||
if (!dontDigest) {
|
if (!dontDigest) {
|
||||||
console.log('[txp digest]');
|
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
console.log('[done digest]');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
w.on('openError', root.onErrorDigest);
|
w.on('openError', root.onErrorDigest);
|
||||||
|
w.on('connectionError', root.onErrorDigest);
|
||||||
w.on('connect', function(peerID) {
|
w.on('connect', function(peerID) {
|
||||||
if (peerID) {
|
if (peerID) {
|
||||||
video.callPeer(peerID, handlePeerVideo);
|
video.callPeer(peerID, handlePeerVideo);
|
||||||
}
|
}
|
||||||
console.log('[digest]');
|
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
});
|
});
|
||||||
w.on('disconnect', function(peerID) {
|
w.on('disconnect', function(peerID) {
|
||||||
|
@ -129,7 +123,6 @@ angular.module('copay.controllerUtils')
|
||||||
$rootScope.availableBalance = safeBalance;
|
$rootScope.availableBalance = safeBalance;
|
||||||
root.updateAddressList();
|
root.updateAddressList();
|
||||||
$rootScope.updatingBalance = false;
|
$rootScope.updatingBalance = false;
|
||||||
console.log('Done updating balance.'); //TODO
|
|
||||||
return cb?cb():null;
|
return cb?cb():null;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -145,7 +138,6 @@ angular.module('copay.controllerUtils')
|
||||||
var inT = w.getTxProposals().sort(function(t1, t2) { return t1.createdTs < t2.createdTs });
|
var inT = w.getTxProposals().sort(function(t1, t2) { return t1.createdTs < t2.createdTs });
|
||||||
var txs = [];
|
var txs = [];
|
||||||
|
|
||||||
console.log('[START LOOP]'); //TODO
|
|
||||||
inT.forEach(function(i, index){
|
inT.forEach(function(i, index){
|
||||||
if (opts.skip && (index < opts.skip[0] || index >= opts.skip[1])) {
|
if (opts.skip && (index < opts.skip[0] || index >= opts.skip[1])) {
|
||||||
return txs.push(null);
|
return txs.push(null);
|
||||||
|
|
Loading…
Reference in New Issue