From cacdefafbf8656b9d6493dfbc86d22209f9eecf2 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Thu, 6 Nov 2014 14:25:48 -0500 Subject: [PATCH] Portal mode authorization Had to override the authorization controller which automatically redirects the user to hte home page if it is their first time visiting tower. I perform a check to see if the url is to /portal, and then set lastPath to portal to force it to portal mode on the first visit --- awx/ui/static/js/app.js | 4 ++++ awx/ui/static/lib/ansible/AuthService.js | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 1d6390c11b..ec889c0302 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -649,6 +649,10 @@ angular.module('Tower', [ $AnsibleConfig = Store('AnsibleConfig'); } + //the authorization controller redirects to the home page automatcially if there is no last path defined. in order to override + // this, set the last path to /portal for instances where portal is visited for the first time. + $rootScope.lastPath = ($location.path() === "/portal") ? 'portal' : undefined; + LoadConfig(); } ]); diff --git a/awx/ui/static/lib/ansible/AuthService.js b/awx/ui/static/lib/ansible/AuthService.js index c782292e8a..2094df56fd 100644 --- a/awx/ui/static/lib/ansible/AuthService.js +++ b/awx/ui/static/lib/ansible/AuthService.js @@ -64,7 +64,16 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) //$rootScope.$destroy(); $cookieStore.remove('token_expires'); $cookieStore.remove('current_user'); - $cookieStore.remove('lastPath'); + + if($cookieStore.get('lastPath')==='/portal'){ + $cookieStore.put( 'lastPath', '/portal'); + $rootScope.lastPath = '/portal'; + } + else { + $cookieStore.remove('lastPath'); + $rootScope.lastPath = '/home'; + } + $cookieStore.remove('token'); $cookieStore.put('userLoggedIn', false); $cookieStore.put('sessionExpired', false); @@ -75,7 +84,7 @@ angular.module('AuthService', ['ngCookies', 'Utilities']) $rootScope.sessionExpired = false; $rootScope.token = null; $rootScope.token_expires = null; - $rootScope.lastPath = '/home'; + $rootScope.login_username = null; $rootScope.login_password = null; },