Merge pull request #6527 from mabashian/6474-login-redirect

Login redirect to clicked link
This commit is contained in:
Greg Considine
2017-06-09 10:08:56 -04:00
committed by GitHub
2 changed files with 17 additions and 6 deletions

View File

@@ -364,6 +364,9 @@ var tower = angular.module('Tower', [
if (!Authorization.getToken() || !Authorization.isUserLoggedIn()) { if (!Authorization.getToken() || !Authorization.isUserLoggedIn()) {
// User not authenticated, redirect to login page // User not authenticated, redirect to login page
if (!/^\/(login|logout)/.test($location.path())) {
$rootScope.preAuthUrl = $location.path();
}
$location.path('/login'); $location.path('/login');
} else { } else {
var lastUser = $cookies.getObject('current_user'), var lastUser = $cookies.getObject('current_user'),

View File

@@ -62,7 +62,7 @@ export default ['$log', '$cookies', '$compile', '$rootScope',
Authorization, Alert, Wait, Timer, Empty, Authorization, Alert, Wait, Timer, Empty,
scope, pendoService, ConfigService, CheckLicense, FeaturesService, scope, pendoService, ConfigService, CheckLicense, FeaturesService,
SocketService) { SocketService) {
var lastPath, lastUser, sessionExpired, loginAgain; var lastPath, lastUser, sessionExpired, loginAgain, preAuthUrl;
loginAgain = function() { loginAgain = function() {
setTimeout(function() { setTimeout(function() {
@@ -88,6 +88,8 @@ export default ['$log', '$cookies', '$compile', '$rootScope',
} }
}; };
preAuthUrl = $rootScope.preAuthUrl;
$log.debug('User session expired: ' + sessionExpired); $log.debug('User session expired: ' + sessionExpired);
$log.debug('Last URL: ' + lastPath()); $log.debug('Last URL: ' + lastPath());
@@ -112,11 +114,17 @@ export default ['$log', '$cookies', '$compile', '$rootScope',
pendoService.issuePendoIdentity(); pendoService.issuePendoIdentity();
FeaturesService.get(); FeaturesService.get();
Wait("stop"); Wait("stop");
if (lastPath() && lastUser()) { if(!Empty(preAuthUrl)){
// Go back to most recent navigation path $location.path(preAuthUrl);
$location.path(lastPath()); delete $rootScope.preAuthUrl;
} else { }
$location.url('/home'); else {
if (lastPath() && lastUser()) {
// Go back to most recent navigation path
$location.path(lastPath());
} else {
$location.url('/home');
}
} }
}) })
.catch(function () { .catch(function () {