mirror of https://github.com/BTCPrivate/copay.git
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
|
@ -1131,7 +1131,7 @@ a.text-warning:hover {color: #FD7262;}
|
|||
|
||||
.wide-page {
|
||||
background-color: #2C3E50;
|
||||
margin: 10% 0;
|
||||
margin: 5% 0;
|
||||
padding: 50px;
|
||||
}
|
||||
|
||||
|
|
12
index.html
12
index.html
|
@ -17,7 +17,8 @@
|
|||
<div class="off-canvas-wrap">
|
||||
<div class="inner-wrap">
|
||||
|
||||
<nav class="tab-bar" ng-class="{'hide-tab-bar' : !$root.wallet || !$root.wallet.isReady()}">
|
||||
<nav class="tab-bar" ng-class="{'hide-tab-bar' : !$root.wallet ||
|
||||
!$root.wallet.isReady() || $root.wallet.isLocked}">
|
||||
<section class="left-small">
|
||||
<a class="left-off-canvas-toggle menu-icon" ><span></span></a>
|
||||
</section>
|
||||
|
@ -39,12 +40,15 @@
|
|||
<div notifications="right top"></div>
|
||||
|
||||
<div
|
||||
ng-class="{'sidebar' : $root.wallet && $root.wallet.isReady()}"
|
||||
ng-class="{'sidebar' : $root.wallet && $root.wallet.isReady() &&
|
||||
!$root.wallet.isLocked}"
|
||||
ng-include="'views/includes/sidebar.html'"
|
||||
role='navigation'
|
||||
ng-if="$root.wallet && $root.wallet.isReady()"></div>
|
||||
ng-if="$root.wallet && $root.wallet.isReady() &&
|
||||
!$root.wallet.isLocked"></div>
|
||||
|
||||
<section ng-class="{'main' : $root.wallet && $root.wallet.isReady()}" ng-view></section>
|
||||
<section ng-class="{'main' : $root.wallet && $root.wallet.isReady() &&
|
||||
!$root.wallet.isLocked}" ng-view></section>
|
||||
|
||||
<a class="exit-off-canvas"></a>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<div class="wide-page" ng-controller="SidebarController"
|
||||
ng-init="checkIfWarning()">
|
||||
<div class="text-center">
|
||||
<img src="img/logo-negative-beta.svg" alt="Copay">
|
||||
<div class="text-white" ng-include="'views/includes/version.html'"></div>
|
||||
</div>
|
||||
<h1 class="text-center text-warning">Warning!</h1>
|
||||
<h3 class="text-center text-white">
|
||||
This wallet appear to be open on an other tab at your browser. Are you sure
|
||||
you want to proceed? (*)
|
||||
</h3>
|
||||
<div class="text-center m30v large-12 columns">
|
||||
<div class="row">
|
||||
<div class="large-6 medium-6 small-6 columns text-center">
|
||||
<a href class="button gray" ng-click="signout()">No, I am not sure.</a>
|
||||
</div>
|
||||
<div class="large-6 columns medium-6 small-6 text-center">
|
||||
<a href class="button warning" ng-click="ignoreLocked()">I am. Go!</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center text-gray small cb">
|
||||
(*) Opening the wallet in multiple tabs could lead to unexpected results
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue