mirror of https://github.com/BTCPrivate/copay.git
feature: Logout wallet after 15 minutes of inactivity
This commit is contained in:
parent
010c13fa4f
commit
f704826a5c
|
@ -21,6 +21,7 @@
|
||||||
"bitcore": "0.1.34",
|
"bitcore": "0.1.34",
|
||||||
"angular-moment": "~0.7.1",
|
"angular-moment": "~0.7.1",
|
||||||
"socket.io-client": ">=1.0.0",
|
"socket.io-client": ">=1.0.0",
|
||||||
"mousetrap": "1.4.6"
|
"mousetrap": "1.4.6",
|
||||||
|
"ng-idle": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
<script src="lib/angular-moment/angular-moment.js"></script>
|
<script src="lib/angular-moment/angular-moment.js"></script>
|
||||||
<script src="lib/qrcode-generator/js/qrcode.js"></script>
|
<script src="lib/qrcode-generator/js/qrcode.js"></script>
|
||||||
<script src="lib/angular-qrcode/qrcode.js"></script>
|
<script src="lib/angular-qrcode/qrcode.js"></script>
|
||||||
|
<script src="lib/ng-idle/angular-idle.min.js"></script>
|
||||||
<script src="lib/angular-foundation/mm-foundation.min.js"></script>
|
<script src="lib/angular-foundation/mm-foundation.min.js"></script>
|
||||||
<script src="lib/angular-foundation/mm-foundation-tpls.min.js"></script>
|
<script src="lib/angular-foundation/mm-foundation-tpls.min.js"></script>
|
||||||
<script src="lib/peer.js"></script> <!-- TODO Change this on PeerJS version 0.3.9 -->
|
<script src="lib/peer.js"></script> <!-- TODO Change this on PeerJS version 0.3.9 -->
|
||||||
|
|
|
@ -27,6 +27,7 @@ var copayApp = window.copayApp = angular.module('copayApp', [
|
||||||
'angularMoment',
|
'angularMoment',
|
||||||
'mm.foundation',
|
'mm.foundation',
|
||||||
'monospaced.qrcode',
|
'monospaced.qrcode',
|
||||||
|
'ngIdle',
|
||||||
'copayApp.filters',
|
'copayApp.filters',
|
||||||
'copayApp.services',
|
'copayApp.services',
|
||||||
'copayApp.controllers',
|
'copayApp.controllers',
|
||||||
|
@ -40,6 +41,7 @@ copayApp.config(function($sceDelegateProvider) {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
angular.module('copayApp.filters', []);
|
angular.module('copayApp.filters', []);
|
||||||
angular.module('copayApp.services', []);
|
angular.module('copayApp.services', []);
|
||||||
angular.module('copayApp.controllers', []);
|
angular.module('copayApp.controllers', []);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('SidebarController',
|
angular.module('copayApp.controllers').controller('SidebarController',
|
||||||
function($scope, $rootScope, $sce, $location, $http, notification, controllerUtils) {
|
function($scope, $rootScope, $sce, $location, $http, $idle, notification, controllerUtils) {
|
||||||
|
|
||||||
$scope.version = copay.version;
|
$scope.version = copay.version;
|
||||||
$scope.networkName = config.networkName;
|
$scope.networkName = config.networkName;
|
||||||
|
@ -82,4 +82,18 @@ angular.module('copayApp.controllers').controller('SidebarController',
|
||||||
// Init socket handlers (with no wallet yet)
|
// Init socket handlers (with no wallet yet)
|
||||||
controllerUtils.setSocketHandlers();
|
controllerUtils.setSocketHandlers();
|
||||||
|
|
||||||
|
if ($rootScope.wallet) {
|
||||||
|
$idle.watch();
|
||||||
|
|
||||||
|
$scope.$on('$idleStart', function(a) {
|
||||||
|
notification.warning('Timing', 'You were enought time in inactivity. This session will be closed in 10 seconds if continues without activity');
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.$on('$idleTimeout', function() {
|
||||||
|
$idle.unwatch();
|
||||||
|
$scope.signout();
|
||||||
|
notification.warning('Session closed', 'Session closed for a long time of inactivity');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,10 +65,13 @@ angular
|
||||||
//Setting HTML5 Location Mode
|
//Setting HTML5 Location Mode
|
||||||
angular
|
angular
|
||||||
.module('copayApp')
|
.module('copayApp')
|
||||||
.config(function($locationProvider) {
|
.config(function($locationProvider, $idleProvider) {
|
||||||
$locationProvider
|
$locationProvider
|
||||||
.html5Mode(false)
|
.html5Mode(false)
|
||||||
.hashPrefix('!');
|
.hashPrefix('!');
|
||||||
|
// IDLE timeout
|
||||||
|
$idleProvider.idleDuration(15 * 60); // in seconds
|
||||||
|
$idleProvider.warningDuration(10); // in seconds
|
||||||
})
|
})
|
||||||
.run(function($rootScope, $location) {
|
.run(function($rootScope, $location) {
|
||||||
$rootScope.$on('$routeChangeStart', function(event, next, current) {
|
$rootScope.$on('$routeChangeStart', function(event, next, current) {
|
||||||
|
|
Loading…
Reference in New Issue