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
commit 4a4fff2bde
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()) {
// User not authenticated, redirect to login page
if (!/^\/(login|logout)/.test($location.path())) {
$rootScope.preAuthUrl = $location.path();
}
$location.path('/login');
} else {
var lastUser = $cookies.getObject('current_user'),

View File

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