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
commit 561b4c3a02
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')
.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/jobs', {
@ -644,6 +643,7 @@ var tower = angular.module('Tower', [
if (!/^\/(login|logout)/.test($location.path())) {
// capture most recent URL, excluding login/logout
$rootScope.lastPath = $location.path();
$rootScope.enteredPath = $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 logout request, clear AuthToken and user session data
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'));

View File

@ -19,7 +19,7 @@
export default
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() {
if ($rootScope.removeLoadConfig) {
@ -42,6 +42,7 @@ angular.module('LoadConfigHelper', ['Utilities'])
});
});
$rootScope.enteredPath = $location.path();
// Load js/local_config.js
$http({ method:'GET', url: $basePath + 'js/local_config.js' })
.success(function(data) {

View File

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