diff --git a/guacamole/src/main/webapp/app/navigation/services/userPageService.js b/guacamole/src/main/webapp/app/navigation/services/userPageService.js index 479ae1a9c..749564bd1 100644 --- a/guacamole/src/main/webapp/app/navigation/services/userPageService.js +++ b/guacamole/src/main/webapp/app/navigation/services/userPageService.js @@ -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.} 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; -}]); \ No newline at end of file +}]);