GUACAMOLE-508: Merge changes which take the user to the system home page if they have administrative access.

This commit is contained in:
Michael Jumper
2018-03-03 12:22:13 -08:00

View File

@@ -57,12 +57,24 @@ angular.module('navigation').factory('userPageService', ['$injector',
* A map of all root connection groups visible to the current user,
* where each key is the identifier of the corresponding data source.
*
* @param {Object.<String, PermissionSet>} permissions
* A map of all permissions granted to the current user, where each
* key is the identifier of the corresponding data source.
*
* @returns {PageDefinition}
* The user's home page.
*/
var generateHomePage = function generateHomePage(rootGroups) {
var generateHomePage = function generateHomePage(rootGroups, permissions) {
var homePage = null;
var settingsPages = generateSettingsPages(permissions);
// If user has access to settings pages, return home page and skip
// evaluation for automatic connections. The Preferences page is
// a Settings page and is always visible, so we look for more than
// one to indicate access to administrative pages.
if (settingsPages.length > 1)
return SYSTEM_HOME_PAGE;
// Determine whether a connection or balancing group should serve as
// the home page
@@ -140,13 +152,23 @@ angular.module('navigation').factory('userPageService', ['$injector',
var deferred = $q.defer();
// Resolve promise using home page derived from root connection groups
dataSourceService.apply(
var getRootGroups = dataSourceService.apply(
connectionGroupService.getConnectionGroupTree,
authenticationService.getAvailableDataSources(),
ConnectionGroup.ROOT_IDENTIFIER
)
.then(function rootConnectionGroupsRetrieved(rootGroups) {
deferred.resolve(generateHomePage(rootGroups));
);
var getPermissionSets = dataSourceService.apply(
permissionService.getPermissions,
authenticationService.getAvailableDataSources(),
authenticationService.getCurrentUsername()
);
$q.all({
rootGroups : getRootGroups,
permissionsSets : getPermissionSets
})
.then(function rootConnectionGroupsPermissionsRetrieved(data) {
deferred.resolve(generateHomePage(data.rootGroups,data.permissionsSets));
});
return deferred.promise;
@@ -342,7 +364,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
var pages = [];
// Get home page and settings pages
var homePage = generateHomePage(rootGroups);
var homePage = generateHomePage(rootGroups, permissions);
var settingsPages = generateSettingsPages(permissions);
// Only include the home page in the list of main pages if the user
@@ -417,4 +439,4 @@ angular.module('navigation').factory('userPageService', ['$injector',
return service;
}]);
}]);