From c96f0234f9c18ab37aa3b1d62a2e516a48af4f46 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Thu, 1 Oct 2015 16:38:37 -0400 Subject: [PATCH] UI side of the session limit includes the 'control' socket, kicking the user out, and adjusting the expireSession function based on the reason --- awx/ui/client/src/app.js | 14 ++++++++++++-- .../login/authenticationServices/timer.factory.js | 13 ++++++++++--- .../src/login/loginModal/loginModal.partial.html | 6 +++++- awx/ui/client/src/rest/interceptors.service.js | 11 ++++++++--- awx/ui/client/src/shared/Socket.js | 2 +- awx/ui/client/src/shared/Utilities.js | 2 +- 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 67f60969e0..36f416a268 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -887,7 +887,7 @@ var tower = angular.module('Tower', [ // Listen for job changes and issue callbacks to initiate // DOM updates function openSocket() { - var schedule_socket; + var schedule_socket, control_socket; sock = Socket({ scope: $rootScope, endpoint: "jobs" }); sock.init(); @@ -936,6 +936,16 @@ var tower = angular.module('Tower', [ $log.debug('Schedule ' + data.unified_job_id + ' status changed to ' + data.status); $rootScope.$emit('ScheduleStatusChange', data); }); + + control_socket = Socket({ + scope: $rootScope, + endpoint: "control" + }); + control_socket.init(); + control_socket.on("limit_reached", function(data) { + $log.debug(data.reason); + Timer.expireSession('session_limit'); + }); } openSocket(); @@ -982,7 +992,7 @@ var tower = angular.module('Tower', [ } else if ($rootScope.sessionTimer.isExpired()) { // gets here on timeout if (next.templateUrl !== (urlPrefix + 'login/loginBackDrop.partial.html')) { - $rootScope.sessionTimer.expireSession(); + $rootScope.sessionTimer.expireSession('idle'); if (sock) { sock.socket.socket.disconnect(); } diff --git a/awx/ui/client/src/login/authenticationServices/timer.factory.js b/awx/ui/client/src/login/authenticationServices/timer.factory.js index 51efe4078d..d5d225b295 100644 --- a/awx/ui/client/src/login/authenticationServices/timer.factory.js +++ b/awx/ui/client/src/login/authenticationServices/timer.factory.js @@ -59,9 +59,16 @@ export default } }, - expireSession: function () { + expireSession: function (reason) { + if(reason === 'session_limit'){ + $rootScope.sessionLimitExpired = true; + $rootScope.sessionExpired = false; + } + else if(reason === 'idle'){ + $rootScope.sessionExpired = true; + $rootScope.sessionLimitExpired = false; + } this.sessionTime = 0; - $rootScope.sessionExpired = true; this.clearTimers(); $cookieStore.put('sessionExpired', true); transitionTo('signOut'); @@ -89,7 +96,7 @@ export default // make a timeout that will go off in 30 mins to log them out // unless they extend their time $rootScope.endTimer = setTimeout(function(){ - that.expireSession(); + that.expireSession('idle'); }, tm * 1000); // notify the user a minute before the end of their session that diff --git a/awx/ui/client/src/login/loginModal/loginModal.partial.html b/awx/ui/client/src/login/loginModal/loginModal.partial.html index 4aadf504fd..8382cce5a5 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.partial.html +++ b/awx/ui/client/src/login/loginModal/loginModal.partial.html @@ -6,13 +6,17 @@ ng-src="/static/assets/{{ customLogo }}" >