From c6879e516336eb090a2128417584d9869ec8f574 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 10 Jun 2016 08:58:46 -0700 Subject: [PATCH 1/4] Adding an extra session check for when a user closes tower before the session times out and returns to Tower. Also changed the login route controller to a resolve to ensure that the login modal appears. --- awx/ui/client/src/app.js | 12 ++++++--- .../src/bread-crumb/bread-crumb.partial.html | 2 +- awx/ui/client/src/footer/footer.partial.html | 2 +- .../authentication.service.js | 15 +++++++---- awx/ui/client/src/login/login.route.js | 18 ++++++++----- .../login/loginModal/loginModal.controller.js | 9 +------ .../login/loginModal/loginModal.partial.html | 4 +-- awx/ui/client/src/login/logout.route.js | 7 +++-- .../src/main-menu/main-menu.partial.html | 26 +++++++++---------- 9 files changed, 54 insertions(+), 41 deletions(-) diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 40d9b1e419..b1933e4198 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -870,11 +870,17 @@ var tower = angular.module('Tower', [ if (!Authorization.getToken() || !Authorization.isUserLoggedIn()) { // User not authenticated, redirect to login page - $rootScope.sessionExpired = false; - $cookieStore.put('sessionExpired', false); - $rootScope.configReady = true; $location.path('/login'); } else { + var lastUser = $cookieStore.get('current_user'), + timestammp = Store('sessionTime'); + if(lastUser && lastUser.id && timestammp && timestammp[lastUser.id]){ + var stime = timestammp[lastUser.id].time, + now = new Date().getTime(); + if ((stime - now) <= 0) { + $location.path('/login'); + } + } // If browser refresh, set the user_is_superuser value $rootScope.user_is_superuser = Authorization.getUserInfo('is_superuser'); // state the user refreshes we want to open the socket, except if the user is on the login page, which should happen after the user logs in (see the AuthService module for that call to OpenSocket) diff --git a/awx/ui/client/src/bread-crumb/bread-crumb.partial.html b/awx/ui/client/src/bread-crumb/bread-crumb.partial.html index 94018460b8..a7c6a6c698 100644 --- a/awx/ui/client/src/bread-crumb/bread-crumb.partial.html +++ b/awx/ui/client/src/bread-crumb/bread-crumb.partial.html @@ -1,4 +1,4 @@ -