Merge pull request #162 from jlmitch5/fix_authentication_routing

fixed authentication routing on the ui
This commit is contained in:
jlmitch5
2015-04-27 17:58:11 -04:00
4 changed files with 18 additions and 2 deletions

View File

@@ -180,7 +180,6 @@ var tower = angular.module('Tower', [
.constant('$timezones.definitions.location', urlPrefix + 'lib/angular-tz-extensions/tz/data') .constant('$timezones.definitions.location', urlPrefix + 'lib/angular-tz-extensions/tz/data')
.config(['$routeProvider', .config(['$routeProvider',
function ($routeProvider) { function ($routeProvider) {
$routeProvider. $routeProvider.
when('/jobs', { when('/jobs', {
@@ -644,6 +643,7 @@ var tower = angular.module('Tower', [
if (!/^\/(login|logout)/.test($location.path())) { if (!/^\/(login|logout)/.test($location.path())) {
// capture most recent URL, excluding login/logout // capture most recent URL, excluding login/logout
$rootScope.lastPath = $location.path(); $rootScope.lastPath = $location.path();
$rootScope.enteredPath = $location.path();
$cookieStore.put('lastPath', $location.path()); $cookieStore.put('lastPath', $location.path());
} }

View File

@@ -105,6 +105,16 @@ export function Authenticate($log, $cookieStore, $compile, $window, $rootScope,
if ($location.path() === '/logout') { if ($location.path() === '/logout') {
//if logout request, clear AuthToken and user session data //if logout request, clear AuthToken and user session data
Authorization.logout(); Authorization.logout();
} else if ($location.path() === '/login') {
if ($rootScope.enteredPath) {
$rootScope.lastPath = $rootScope.enteredPath;
} else if (!$rootScope.lastPath) {
// your last path was home
$cookieStore.remove('lastPath');
$rootScope.lastPath = '/home';
}
} else {
$rootScope.enteredPath = $location.path();
} }
e = angular.element(document.getElementById('login-modal-content')); e = angular.element(document.getElementById('login-modal-content'));

View File

@@ -19,7 +19,7 @@
export default export default
angular.module('LoadConfigHelper', ['Utilities']) angular.module('LoadConfigHelper', ['Utilities'])
.factory('LoadConfig', ['$log', '$rootScope', '$http', 'ProcessErrors', 'Store', function($log, $rootScope, $http, ProcessErrors, Store) { .factory('LoadConfig', ['$log', '$rootScope', '$http', '$location', 'ProcessErrors', 'Store', function($log, $rootScope, $http, $location, ProcessErrors, Store) {
return function() { return function() {
if ($rootScope.removeLoadConfig) { if ($rootScope.removeLoadConfig) {
@@ -42,6 +42,7 @@ angular.module('LoadConfigHelper', ['Utilities'])
}); });
}); });
$rootScope.enteredPath = $location.path();
// Load js/local_config.js // Load js/local_config.js
$http({ method:'GET', url: $basePath + 'js/local_config.js' }) $http({ method:'GET', url: $basePath + 'js/local_config.js' })
.success(function(data) { .success(function(data) {

View File

@@ -70,7 +70,12 @@ angular.module('AuthService', ['ngCookies', Utilities.name])
$cookieStore.put( 'lastPath', '/portal'); $cookieStore.put( 'lastPath', '/portal');
$rootScope.lastPath = '/portal'; $rootScope.lastPath = '/portal';
} }
else if ($cookieStore.get('lastPath') !== '/home' || $cookieStore.get('lastPath') !== '/'){
// do nothing
$rootScope.lastPath = $cookieStore.get('lastPath');
}
else { else {
// your last path was home
$cookieStore.remove('lastPath'); $cookieStore.remove('lastPath');
$rootScope.lastPath = '/home'; $rootScope.lastPath = '/home';
} }