Adds logic to redirect unauthenticated user if LOGIN_REDIRECT_OVERRIDE is set as long as the user is not navigating to /login or /#/login. Also redirects on logout if LOGIN_REDIRECT_OVERRIDE is set.

This commit is contained in:
mabashian
2019-12-11 09:19:38 -05:00
committed by Graham Mainwaring
parent 732da52239
commit d899e75ad7
3 changed files with 23 additions and 7 deletions

View File

@@ -375,7 +375,13 @@ angular
if (!/^\/(login|logout)/.test($location.path())) { if (!/^\/(login|logout)/.test($location.path())) {
$rootScope.preAuthUrl = $location.path(); $rootScope.preAuthUrl = $location.path();
} }
$location.path('/login'); if ($location.path() !== '/login') {
if (global.$AnsibleConfig.login_redirect_override) {
window.location.replace(global.$AnsibleConfig.login_redirect_override);
} else {
$location.path('/login');
}
}
} else { } else {
var lastUser = $cookies.getObject('current_user'), var lastUser = $cookies.getObject('current_user'),
timestammp = Store('sessionTime'); timestammp = Store('sessionTime');
@@ -383,7 +389,11 @@ angular
var stime = timestammp[lastUser.id].time, var stime = timestammp[lastUser.id].time,
now = new Date().getTime(); now = new Date().getTime();
if ((stime - now) <= 0) { if ((stime - now) <= 0) {
$location.path('/login'); if (global.$AnsibleConfig.login_redirect_override) {
window.location.replace(global.$AnsibleConfig.login_redirect_override);
} else {
$location.path('/login');
}
} }
} }
// If browser refresh, set the user_is_superuser value // If browser refresh, set the user_is_superuser value

View File

@@ -11,7 +11,11 @@ export default {
route: '/logout', route: '/logout',
controller: ['Authorization', '$state', function(Authorization, $state) { controller: ['Authorization', '$state', function(Authorization, $state) {
Authorization.logout().then( () =>{ Authorization.logout().then( () =>{
$state.go('signIn'); if (global.$AnsibleConfig.login_redirect_override) {
window.location.replace(global.$AnsibleConfig.login_redirect_override);
} else {
$state.go('signIn');
}
}); });
}], }],

View File

@@ -2,7 +2,6 @@ export default
function LoadConfig($log, $rootScope, $http, Store) { function LoadConfig($log, $rootScope, $http, Store) {
return function() { return function() {
var configSettings = {}; var configSettings = {};
var configInit = function() { var configInit = function() {
@@ -10,12 +9,11 @@ export default
if ($rootScope.loginConfig) { if ($rootScope.loginConfig) {
$rootScope.loginConfig.resolve('config loaded'); $rootScope.loginConfig.resolve('config loaded');
} }
global.$AnsibleConfig = configSettings;
Store('AnsibleConfig', global.$AnsibleConfig);
$rootScope.$emit('ConfigReady'); $rootScope.$emit('ConfigReady');
// Load new hardcoded settings from above // Load new hardcoded settings from above
global.$AnsibleConfig = configSettings;
Store('AnsibleConfig', global.$AnsibleConfig);
$rootScope.$emit('LoadConfig'); $rootScope.$emit('LoadConfig');
}; };
@@ -39,6 +37,10 @@ export default
configSettings.custom_login_info = false; configSettings.custom_login_info = false;
} }
if (data.login_redirect_override) {
configSettings.login_redirect_override = data.login_redirect_override;
}
configInit(); configInit();
}).catch(({error}) => { }).catch(({error}) => {