diff --git a/guacamole/src/main/webapp/app/rest/services/permissionService.js b/guacamole/src/main/webapp/app/rest/services/permissionService.js index 3bcb1fb0f..57760191d 100644 --- a/guacamole/src/main/webapp/app/rest/services/permissionService.js +++ b/guacamole/src/main/webapp/app/rest/services/permissionService.js @@ -104,6 +104,10 @@ angular.module('rest').factory('permissionService', ['$http', 'authenticationSer * @param {String} operation * The operation to specify within each of the patches. Valid values * for this are defined within PermissionPatch.Operation. + * + * @param {String} path + * The path of the permissions being patched. The path is a JSON path + * describing the position of the permissions within a PermissionSet. * * @param {Object.} permissions * A map of object identifiers to arrays of permission type strings, @@ -114,10 +118,12 @@ angular.module('rest').factory('permissionService', ['$http', 'authenticationSer // Add object permission operations to patch for (var identifier in permissions) { - patch.push({ - op : operation, - path : path + "/" + identifier, - value : permissions[identifier] + permissions[identifier].forEach(function addObjectPatch(type) { + patch.push({ + op : operation, + path : path + "/" + identifier, + value : type + }); }); } @@ -152,13 +158,13 @@ angular.module('rest').factory('permissionService', ['$http', 'authenticationSer permissions.userPermissions); // Add system operations to patch - if (permissions.systemPermissions.length) { + permissions.systemPermissions.forEach(function addSystemPatch(type) { patch.push({ op : operation, path : "/systemPermissions", - value : permissions.systemPermissions + value : type }); - } + }); }; diff --git a/guacamole/src/main/webapp/app/rest/types/PermissionPatch.js b/guacamole/src/main/webapp/app/rest/types/PermissionPatch.js index 729e7a63a..9f3aa8861 100644 --- a/guacamole/src/main/webapp/app/rest/types/PermissionPatch.js +++ b/guacamole/src/main/webapp/app/rest/types/PermissionPatch.js @@ -59,15 +59,15 @@ angular.module('rest').factory('PermissionPatch', [function definePermissionPatc this.path = template.path; /** - * The array of permissions. If the permission applies to an object, - * such as a connection or connection group, these will be values from - * PermissionSet.ObjectPermissionType. If the permission applies to - * the system as a whole (the path is "/systemPermissions"), these will - * be values from PermissionSet.SystemPermissionType. + * The permissions being added or removed. If the permission applies to + * an object, such as a connection or connection group, this will be a + * value from PermissionSet.ObjectPermissionType. If the permission + * applies to the system as a whole (the path is "/systemPermissions"), + * this will be a value from PermissionSet.SystemPermissionType. * - * @type String[] + * @type String */ - this.value = template.value || []; + this.value = template.value; }; @@ -78,12 +78,12 @@ angular.module('rest').factory('PermissionPatch', [function definePermissionPatc PermissionPatch.Operation = { /** - * Adds (grants) the specified permissions. + * Adds (grants) the specified permission. */ ADD : "add", /** - * Removes (revokes) the specified permissions. + * Removes (revokes) the specified permission. */ REMOVE : "remove"