mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUAC-586: Add data source to user and permissions services.
This commit is contained in:
		| @@ -41,6 +41,11 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      * given user, returning a promise that provides an array of | ||||
|      * @link{Permission} objects if successful. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user whose | ||||
|      *     permissions should be retrieved. This identifier corresponds to an | ||||
|      *     AuthenticationProvider within the Guacamole web application. | ||||
|      * | ||||
|      * @param {String} userID | ||||
|      *     The ID of the user to retrieve the permissions for. | ||||
|      *                           | ||||
| @@ -48,7 +53,7 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      *     A promise which will resolve with a @link{PermissionSet} upon | ||||
|      *     success. | ||||
|      */ | ||||
|     service.getPermissions = function getPermissions(userID) { | ||||
|     service.getPermissions = function getPermissions(dataSource, userID) { | ||||
|  | ||||
|         // Build HTTP parameters set | ||||
|         var httpParameters = { | ||||
| @@ -59,7 +64,7 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|         return $http({ | ||||
|             cache   : cacheService.users, | ||||
|             method  : 'GET', | ||||
|             url     : 'api/users/' + encodeURIComponent(userID) + '/permissions', | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(userID) + '/permissions', | ||||
|             params  : httpParameters | ||||
|         }); | ||||
|  | ||||
| @@ -70,6 +75,11 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      * returning a promise that can be used for processing the results of the | ||||
|      * call. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user whose | ||||
|      *     permissions should be modified. This identifier corresponds to an | ||||
|      *     AuthenticationProvider within the Guacamole web application. | ||||
|      * | ||||
|      * @param {String} userID | ||||
|      *     The ID of the user to modify the permissions of. | ||||
|      *                           | ||||
| @@ -80,8 +90,8 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      *     A promise for the HTTP call which will succeed if and only if the | ||||
|      *     add operation is successful. | ||||
|      */ | ||||
|     service.addPermissions = function addPermissions(userID, permissions) { | ||||
|         return service.patchPermissions(userID, permissions, null); | ||||
|     service.addPermissions = function addPermissions(dataSource, userID, permissions) { | ||||
|         return service.patchPermissions(dataSource, userID, permissions, null); | ||||
|     }; | ||||
|      | ||||
|     /** | ||||
| @@ -89,6 +99,11 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      * returning a promise that can be used for processing the results of the | ||||
|      * call. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user whose | ||||
|      *     permissions should be modified. This identifier corresponds to an | ||||
|      *     AuthenticationProvider within the Guacamole web application. | ||||
|      * | ||||
|      * @param {String} userID | ||||
|      *     The ID of the user to modify the permissions of. | ||||
|      *                           | ||||
| @@ -99,8 +114,8 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      *     A promise for the HTTP call which will succeed if and only if the | ||||
|      *     remove operation is successful. | ||||
|      */ | ||||
|     service.removePermissions = function removePermissions(userID, permissions) { | ||||
|         return service.patchPermissions(userID, null, permissions); | ||||
|     service.removePermissions = function removePermissions(dataSource, userID, permissions) { | ||||
|         return service.patchPermissions(dataSource, userID, null, permissions); | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
| @@ -186,6 +201,11 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      * user, returning a promise that can be used for processing the results of | ||||
|      * the call. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user whose | ||||
|      *     permissions should be modified. This identifier corresponds to an | ||||
|      *     AuthenticationProvider within the Guacamole web application. | ||||
|      * | ||||
|      * @param {String} userID | ||||
|      *     The ID of the user to modify the permissions of. | ||||
|      *                           | ||||
| @@ -199,7 +219,7 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|      *     A promise for the HTTP call which will succeed if and only if the | ||||
|      *     patch operation is successful. | ||||
|      */ | ||||
|     service.patchPermissions = function patchPermissions(userID, permissionsToAdd, permissionsToRemove) { | ||||
|     service.patchPermissions = function patchPermissions(dataSource, userID, permissionsToAdd, permissionsToRemove) { | ||||
|  | ||||
|         var permissionPatch = []; | ||||
|          | ||||
| @@ -217,7 +237,7 @@ angular.module('rest').factory('permissionService', ['$injector', | ||||
|         // Patch user permissions | ||||
|         return $http({ | ||||
|             method  : 'PATCH',  | ||||
|             url     : 'api/users/' + encodeURIComponent(userID) + '/permissions', | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(userID) + '/permissions', | ||||
|             params  : httpParameters, | ||||
|             data    : permissionPatch | ||||
|         }) | ||||
|   | ||||
| @@ -41,6 +41,11 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      * returning a promise that provides an array of @link{User} objects if | ||||
|      * successful. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the users to be | ||||
|      *     retrieved. This identifier corresponds to an AuthenticationProvider | ||||
|      *     within the Guacamole web application. | ||||
|      * | ||||
|      * @param {String[]} [permissionTypes] | ||||
|      *     The set of permissions to filter with. A user must have one or more | ||||
|      *     of these permissions for a user to appear in the result.  | ||||
| @@ -51,7 +56,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      *     A promise which will resolve with an array of @link{User} objects | ||||
|      *     upon success. | ||||
|      */ | ||||
|     service.getUsers = function getUsers(permissionTypes) { | ||||
|     service.getUsers = function getUsers(dataSource, permissionTypes) { | ||||
|  | ||||
|         // Build HTTP parameters set | ||||
|         var httpParameters = { | ||||
| @@ -66,7 +71,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|         return $http({ | ||||
|             cache   : cacheService.users, | ||||
|             method  : 'GET', | ||||
|             url     : 'api/users', | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users', | ||||
|             params  : httpParameters | ||||
|         }); | ||||
|  | ||||
| @@ -76,14 +81,19 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      * Makes a request to the REST API to get the user having the given | ||||
|      * username, returning a promise that provides the corresponding | ||||
|      * @link{User} if successful. | ||||
|      *  | ||||
|      * | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user to be | ||||
|      *     retrieved. This identifier corresponds to an AuthenticationProvider | ||||
|      *     within the Guacamole web application. | ||||
|      * | ||||
|      * @param {String} username | ||||
|      *     The username of the user to retrieve. | ||||
|      *  | ||||
|      * @returns {Promise.<User>} | ||||
|      *     A promise which will resolve with a @link{User} upon success. | ||||
|      */ | ||||
|     service.getUser = function getUser(username) { | ||||
|     service.getUser = function getUser(dataSource, username) { | ||||
|  | ||||
|         // Build HTTP parameters set | ||||
|         var httpParameters = { | ||||
| @@ -94,7 +104,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|         return $http({ | ||||
|             cache   : cacheService.users, | ||||
|             method  : 'GET', | ||||
|             url     : 'api/users/' + encodeURIComponent(username), | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username), | ||||
|             params  : httpParameters | ||||
|         }); | ||||
|  | ||||
| @@ -104,6 +114,11 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      * Makes a request to the REST API to delete a user, returning a promise | ||||
|      * that can be used for processing the results of the call. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user to be | ||||
|      *     deleted. This identifier corresponds to an AuthenticationProvider | ||||
|      *     within the Guacamole web application. | ||||
|      * | ||||
|      * @param {User} user | ||||
|      *     The user to delete. | ||||
|      *                           | ||||
| @@ -111,7 +126,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      *     A promise for the HTTP call which will succeed if and only if the | ||||
|      *     delete operation is successful. | ||||
|      */ | ||||
|     service.deleteUser = function deleteUser(user) { | ||||
|     service.deleteUser = function deleteUser(dataSource, user) { | ||||
|  | ||||
|         // Build HTTP parameters set | ||||
|         var httpParameters = { | ||||
| @@ -121,7 +136,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|         // Delete user | ||||
|         return $http({ | ||||
|             method  : 'DELETE', | ||||
|             url     : 'api/users/' + encodeURIComponent(user.username), | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username), | ||||
|             params  : httpParameters | ||||
|         }) | ||||
|  | ||||
| @@ -137,6 +152,11 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      * Makes a request to the REST API to create a user, returning a promise | ||||
|      * that can be used for processing the results of the call. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source in which the user should be | ||||
|      *     created. This identifier corresponds to an AuthenticationProvider | ||||
|      *     within the Guacamole web application. | ||||
|      * | ||||
|      * @param {User} user | ||||
|      *     The user to create. | ||||
|      *                           | ||||
| @@ -144,7 +164,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      *     A promise for the HTTP call which will succeed if and only if the | ||||
|      *     create operation is successful. | ||||
|      */ | ||||
|     service.createUser = function createUser(user) { | ||||
|     service.createUser = function createUser(dataSource, user) { | ||||
|  | ||||
|         // Build HTTP parameters set | ||||
|         var httpParameters = { | ||||
| @@ -154,7 +174,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|         // Create user | ||||
|         return $http({ | ||||
|             method  : 'POST', | ||||
|             url     : 'api/users', | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users', | ||||
|             params  : httpParameters, | ||||
|             data    : user | ||||
|         }) | ||||
| @@ -170,6 +190,11 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      * Makes a request to the REST API to save a user, returning a promise that | ||||
|      * can be used for processing the results of the call. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user to be | ||||
|      *     updated. This identifier corresponds to an AuthenticationProvider | ||||
|      *     within the Guacamole web application. | ||||
|      * | ||||
|      * @param {User} user | ||||
|      *     The user to update. | ||||
|      *                           | ||||
| @@ -177,7 +202,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      *     A promise for the HTTP call which will succeed if and only if the | ||||
|      *     save operation is successful. | ||||
|      */ | ||||
|     service.saveUser = function saveUser(user) { | ||||
|     service.saveUser = function saveUser(dataSource, user) { | ||||
|  | ||||
|         // Build HTTP parameters set | ||||
|         var httpParameters = { | ||||
| @@ -187,7 +212,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|         // Update user | ||||
|         return $http({ | ||||
|             method  : 'PUT', | ||||
|             url     : 'api/users/' + encodeURIComponent(user.username), | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(user.username), | ||||
|             params  : httpParameters, | ||||
|             data    : user | ||||
|         }) | ||||
| @@ -203,6 +228,11 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      * Makes a request to the REST API to update the password for a user,  | ||||
|      * returning a promise that can be used for processing the results of the call. | ||||
|      *  | ||||
|      * @param {String} dataSource | ||||
|      *     The unique identifier of the data source containing the user to be | ||||
|      *     updated. This identifier corresponds to an AuthenticationProvider | ||||
|      *     within the Guacamole web application. | ||||
|      * | ||||
|      * @param {String} username | ||||
|      *     The username of the user to update. | ||||
|      *      | ||||
| @@ -216,7 +246,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|      *     A promise for the HTTP call which will succeed if and only if the | ||||
|      *     password update operation is successful. | ||||
|      */ | ||||
|     service.updateUserPassword = function updateUserPassword(username,  | ||||
|     service.updateUserPassword = function updateUserPassword(dataSource, username, | ||||
|             oldPassword, newPassword) { | ||||
|  | ||||
|         // Build HTTP parameters set | ||||
| @@ -227,7 +257,7 @@ angular.module('rest').factory('userService', ['$injector', | ||||
|         // Update user password | ||||
|         return $http({ | ||||
|             method  : 'PUT', | ||||
|             url     : 'api/users/' + encodeURIComponent(username) + '/password', | ||||
|             url     : 'api/data/' + encodeURIComponent(dataSource) + '/users/' + encodeURIComponent(username) + '/password', | ||||
|             params  : httpParameters, | ||||
|             data    : new UserPasswordUpdate({ | ||||
|                 oldPassword : oldPassword, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user