mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUAC-1161: Reject attempts to visit '/' unless '/' is actually the home page. Redirect to true home page otherwise.
This commit is contained in:
@@ -74,8 +74,8 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
|
|||||||
var $q = $injector.get('$q');
|
var $q = $injector.get('$q');
|
||||||
var userPageService = $injector.get('userPageService');
|
var userPageService = $injector.get('userPageService');
|
||||||
|
|
||||||
// Promise for redirection attempt
|
// Promise for routing attempt
|
||||||
var redirect = $q.defer();
|
var route = $q.defer();
|
||||||
|
|
||||||
// Re-authenticate including any parameters in URL
|
// Re-authenticate including any parameters in URL
|
||||||
$injector.invoke(updateCurrentToken)
|
$injector.invoke(updateCurrentToken)
|
||||||
@@ -84,23 +84,29 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
|
|||||||
// Redirect to home page
|
// Redirect to home page
|
||||||
userPageService.getHomePage()
|
userPageService.getHomePage()
|
||||||
.then(function homePageRetrieved(homePage) {
|
.then(function homePageRetrieved(homePage) {
|
||||||
$location.url(homePage.url);
|
|
||||||
|
// If home page is the requested location, allow through
|
||||||
|
if ($location.path() === homePage.url)
|
||||||
|
route.resolve();
|
||||||
|
|
||||||
|
// Otherwise, reject and reroute
|
||||||
|
else {
|
||||||
|
$location.url(homePage.url);
|
||||||
|
route.reject();
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// If retrieval of home page fails, assume '/'
|
// If retrieval of home page fails, assume requested page is OK
|
||||||
['catch'](function homePageFailed() {
|
['catch'](function homePageFailed() {
|
||||||
$location.url('/');
|
route.resolve();
|
||||||
})
|
|
||||||
|
|
||||||
// Resolve promise in either case
|
|
||||||
['finally'](function retrievalAttemptComplete() {
|
|
||||||
redirect.resolve();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return promise that will resolve regardless of success/failure
|
// Return promise that will resolve only if the requested page is the
|
||||||
return redirect.promise;
|
// home page
|
||||||
|
return route.promise;
|
||||||
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user