Store the url that the user comes in on before auth in preAuthUrl

This commit is contained in:
Michael Abashian 2017-06-08 19:01:44 -04:00
parent fc312398cd
commit 7768106d3f
3 changed files with 17 additions and 11 deletions

View File

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

View File

@ -103,7 +103,7 @@ export default
Store('sessionTime', x);
if ($cookies.getObject('current_user')) {
$cookies.put( 'lastUser', $cookies.getObject('current_user').id);
$rootScope.lastUser = $cookies.getObject('current_user').id;
}
ConfigService.delete();
SocketService.disconnect();

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() {
@ -80,8 +80,7 @@ export default ['$log', '$cookies', '$compile', '$rootScope',
};
lastUser = function(){
let lastUser = $cookies.get('lastUser');
if(!Empty(lastUser) && parseInt(lastUser) === $rootScope.current_user.id){
if(!Empty($rootScope.lastUser) && $rootScope.lastUser === $rootScope.current_user.id){
return true;
}
else {
@ -89,6 +88,8 @@ export default ['$log', '$cookies', '$compile', '$rootScope',
}
};
preAuthUrl = $cookies.get('preAuthUrl');
$log.debug('User session expired: ' + sessionExpired);
$log.debug('Last URL: ' + lastPath());
@ -113,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);
$cookies.remove('preAuthUrl');
}
else {
if (lastPath() && lastUser()) {
// Go back to most recent navigation path
$location.path(lastPath());
} else {
$location.url('/home');
}
}
})
.catch(function () {