Show a warning if trying to open same wallet in same browser. Fix redirect to receive.
This commit is contained in:
parent
fe53f1b87c
commit
801e746d11
8 changed files with 93 additions and 6 deletions
|
|
@ -74,4 +74,15 @@ angular.module('copayApp.controllers').controller('SidebarController',
|
|||
});
|
||||
}
|
||||
|
||||
$scope.checkIfWarning = function() {
|
||||
if (!$rootScope.wallet.isLocked) {
|
||||
controllerUtils.redirIfLogged();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.ignoreLocked = function() {
|
||||
$rootScope.wallet.isLocked = false;
|
||||
controllerUtils.redirIfLogged();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -92,6 +92,27 @@ Wallet.prototype.connectToAll = function() {
|
|||
}
|
||||
};
|
||||
|
||||
Wallet.prototype.getIsOpen = function() {
|
||||
return this.storage.getIsOpen(this.id);
|
||||
};
|
||||
|
||||
Wallet.prototype.setIsOpen = function() {
|
||||
return this.storage.setIsOpen(this.id);
|
||||
};
|
||||
|
||||
Wallet.prototype.closeIfOpen = function() {
|
||||
this.storage.removeIsOpen(this.id);
|
||||
};
|
||||
|
||||
Wallet.prototype._checkLocked = function() {
|
||||
if (this.getIsOpen()) {
|
||||
this.isLocked = true;
|
||||
}
|
||||
else {
|
||||
this.setIsOpen();
|
||||
}
|
||||
};
|
||||
|
||||
Wallet.prototype._handleIndexes = function(senderId, data, isInbound) {
|
||||
this.log('RECV INDEXES:', data);
|
||||
var inIndexes = HDParams.fromList(data.indexes);
|
||||
|
|
@ -409,6 +430,9 @@ Wallet.prototype._lockIncomming = function() {
|
|||
Wallet.prototype.netStart = function(callback) {
|
||||
var self = this;
|
||||
var net = this.network;
|
||||
|
||||
this._checkLocked();
|
||||
|
||||
net.removeAllListeners();
|
||||
net.on('connect', self._handleConnect.bind(self));
|
||||
net.on('disconnect', self._handleDisconnect.bind(self));
|
||||
|
|
|
|||
|
|
@ -180,6 +180,18 @@ Storage.prototype.getLastOpened = function() {
|
|||
return this.getGlobal('lastOpened');
|
||||
}
|
||||
|
||||
Storage.prototype.setIsOpen = function(walletId) {
|
||||
this.setGlobal(this._key(walletId, 'isOpen'), true);
|
||||
}
|
||||
|
||||
Storage.prototype.getIsOpen = function(walletId) {
|
||||
return this.getGlobal(this._key(walletId, 'isOpen'));
|
||||
}
|
||||
|
||||
Storage.prototype.removeIsOpen = function(walletId) {
|
||||
this.localStorage.removeItem(this._key(walletId, 'isOpen'));
|
||||
}
|
||||
|
||||
//obj contains keys to be set
|
||||
Storage.prototype.setFromObj = function(walletId, obj) {
|
||||
for (var k in obj) {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@ angular
|
|||
.when('/uri-payment/:data', {
|
||||
templateUrl: 'views/uri-payment.html'
|
||||
})
|
||||
.when('/warning', {
|
||||
templateUrl: 'views/warning.html',
|
||||
validate: true
|
||||
})
|
||||
.otherwise({
|
||||
templateUrl: 'views/errors/404.html',
|
||||
title: 'Error'
|
||||
|
|
@ -86,6 +90,9 @@ angular
|
|||
if ($rootScope.wallet && !$rootScope.wallet.isReady()) {
|
||||
$location.path('/copayers');
|
||||
}
|
||||
if ($rootScope.wallet && $rootScope.wallet.isLocked) {
|
||||
$location.path('/warning');
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,11 +17,14 @@ angular.module('copayApp.services')
|
|||
root.redirIfLogged = function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (w) {
|
||||
$location.path('addresses');
|
||||
$location.path('receive');
|
||||
}
|
||||
};
|
||||
|
||||
root.logout = function() {
|
||||
if (!$rootScope.wallet.isLocked) {
|
||||
$rootScope.wallet.closeIfOpen();
|
||||
}
|
||||
Socket.removeAllListeners();
|
||||
|
||||
$rootScope.wallet = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue