GUACAMOLE-1656: Fix user preferences permissioning.

This commit is contained in:
James Muehlner
2022-11-22 20:32:18 +00:00
parent b315e6aac8
commit c82ca370e2
5 changed files with 29 additions and 23 deletions

View File

@@ -143,12 +143,13 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
$scope.newPasswordMatch = null;
/**
* Whether the current user can change their own password, or null
* if this is not yet known.
* Whether the current user can edit themselves - i.e. update their
* password or change user preference attributes, or null if this
* is not yet known.
*
* @type Boolean
*/
$scope.canChangePassword = null;
$scope.canUpdateSelf = null;
/**
* Update the current user's password to the password currently set within
@@ -206,13 +207,13 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
permissionService.getEffectivePermissions(dataSource, username)
.then(function permissionsRetrieved(permissions) {
// Add action for changing password if permission is granted
$scope.canChangePassword = PermissionSet.hasUserPermission(permissions,
// Add action for updaing password or user preferences if permission is granted
$scope.canUpdateSelf = PermissionSet.hasUserPermission(permissions,
PermissionSet.ObjectPermissionType.UPDATE, username);
})
['catch'](requestService.createErrorCallback(function permissionsFailed(error) {
$scope.canChangePassword = false;
$scope.canUpdateSelf = false;
}));
/**
@@ -224,8 +225,8 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
*/
$scope.isLoaded = function isLoaded() {
return $scope.canChangePassword !== null
&& $scope.languages !== null;
return $scope.canUpdateSelf !== null
&& $scope.languages !== null;
};

View File

@@ -7,8 +7,8 @@
</div>
<!-- Password update -->
<h2 class="header" ng-show="canChangePassword">{{'SETTINGS_PREFERENCES.SECTION_HEADER_UPDATE_PASSWORD' | translate}}</h2>
<div class="settings section update-password" ng-show="canChangePassword">
<h2 class="header" ng-show="canUpdateSelf">{{'SETTINGS_PREFERENCES.SECTION_HEADER_UPDATE_PASSWORD' | translate}}</h2>
<div class="settings section update-password" ng-show="canUpdateSelf">
<p>{{'SETTINGS_PREFERENCES.HELP_UPDATE_PASSWORD' | translate}}</p>
<!-- Password editor -->
@@ -90,7 +90,7 @@
</div>
<!-- User attributes section -->
<div class="attributes" ng-show="attributes.length">
<div class="attributes" ng-show="canUpdateSelf && attributes.length">
<guac-form namespace="'USER_ATTRIBUTES'" content="attributes"
model="user.attributes"></guac-form>