diff --git a/bower.json b/bower.json
index cf1a4f301..ed357189c 100644
--- a/bower.json
+++ b/bower.json
@@ -21,6 +21,7 @@
"bitcore": "0.1.34",
"angular-moment": "~0.7.1",
"socket.io-client": ">=1.0.0",
- "mousetrap": "1.4.6"
+ "mousetrap": "1.4.6",
+ "ng-idle": "*"
}
}
diff --git a/index.html b/index.html
index acc29b64d..6369c9331 100644
--- a/index.html
+++ b/index.html
@@ -62,6 +62,7 @@
+
diff --git a/js/app.js b/js/app.js
index cf5656438..058dfbba6 100644
--- a/js/app.js
+++ b/js/app.js
@@ -27,6 +27,7 @@ var copayApp = window.copayApp = angular.module('copayApp', [
'angularMoment',
'mm.foundation',
'monospaced.qrcode',
+ 'ngIdle',
'copayApp.filters',
'copayApp.services',
'copayApp.controllers',
@@ -40,6 +41,7 @@ copayApp.config(function($sceDelegateProvider) {
]);
});
+
angular.module('copayApp.filters', []);
angular.module('copayApp.services', []);
angular.module('copayApp.controllers', []);
diff --git a/js/controllers/sidebar.js b/js/controllers/sidebar.js
index 79b8ad859..92917054f 100644
--- a/js/controllers/sidebar.js
+++ b/js/controllers/sidebar.js
@@ -1,7 +1,7 @@
'use strict';
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.networkName = config.networkName;
@@ -82,4 +82,18 @@ angular.module('copayApp.controllers').controller('SidebarController',
// Init socket handlers (with no wallet yet)
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');
+ });
+ }
+
});
diff --git a/js/routes.js b/js/routes.js
index 9db46fdc1..192d44609 100644
--- a/js/routes.js
+++ b/js/routes.js
@@ -65,10 +65,13 @@ angular
//Setting HTML5 Location Mode
angular
.module('copayApp')
- .config(function($locationProvider) {
+ .config(function($locationProvider, $idleProvider) {
$locationProvider
.html5Mode(false)
.hashPrefix('!');
+ // IDLE timeout
+ $idleProvider.idleDuration(15 * 60); // in seconds
+ $idleProvider.warningDuration(10); // in seconds
})
.run(function($rootScope, $location) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {