mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-220: Merge ignore missing user or group when retrieving permissions/memberships.
This commit is contained in:
@@ -248,20 +248,27 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
|||||||
var loadExistingUser = function loadExistingUser(dataSource, username) {
|
var loadExistingUser = function loadExistingUser(dataSource, username) {
|
||||||
return $q.all({
|
return $q.all({
|
||||||
users : dataSourceService.apply(userService.getUser, dataSources, username),
|
users : dataSourceService.apply(userService.getUser, dataSources, username),
|
||||||
permissions : permissionService.getPermissions(dataSource, username),
|
|
||||||
parentGroups : membershipService.getUserGroups(dataSource, username)
|
// Use empty permission set if user cannot be found
|
||||||
|
permissions:
|
||||||
|
permissionService.getPermissions(dataSource, username)
|
||||||
|
['catch'](requestService.defaultValue(new PermissionSet())),
|
||||||
|
|
||||||
|
// Assume no parent groups if user cannot be found
|
||||||
|
parentGroups:
|
||||||
|
membershipService.getUserGroups(dataSource, username)
|
||||||
|
['catch'](requestService.defaultValue([]))
|
||||||
|
|
||||||
})
|
})
|
||||||
.then(function userDataRetrieved(values) {
|
.then(function userDataRetrieved(values) {
|
||||||
|
|
||||||
$scope.users = values.users;
|
$scope.users = values.users;
|
||||||
$scope.user = values.users[dataSource];
|
|
||||||
$scope.parentGroups = values.parentGroups;
|
$scope.parentGroups = values.parentGroups;
|
||||||
|
|
||||||
// Create skeleton user if user does not exist
|
// Create skeleton user if user does not exist
|
||||||
if (!$scope.user)
|
$scope.user = values.users[dataSource] || new User({
|
||||||
$scope.user = new User({
|
'username' : username
|
||||||
'username' : username
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// The current user will be associated with username of the existing
|
// The current user will be associated with username of the existing
|
||||||
// user in the retrieved permission set
|
// user in the retrieved permission set
|
||||||
|
@@ -303,24 +303,39 @@ angular.module('manage').controller('manageUserGroupController', ['$scope', '$in
|
|||||||
var loadExistingUserGroup = function loadExistingGroup(dataSource, identifier) {
|
var loadExistingUserGroup = function loadExistingGroup(dataSource, identifier) {
|
||||||
return $q.all({
|
return $q.all({
|
||||||
userGroups : dataSourceService.apply(userGroupService.getUserGroup, dataSources, identifier),
|
userGroups : dataSourceService.apply(userGroupService.getUserGroup, dataSources, identifier),
|
||||||
permissions : permissionService.getPermissions(dataSource, identifier, true),
|
|
||||||
parentGroups : membershipService.getUserGroups(dataSource, identifier, true),
|
// Use empty permission set if group cannot be found
|
||||||
memberGroups : membershipService.getMemberUserGroups(dataSource, identifier),
|
permissions:
|
||||||
memberUsers : membershipService.getMemberUsers(dataSource, identifier)
|
permissionService.getPermissions(dataSource, identifier, true)
|
||||||
|
['catch'](requestService.defaultValue(new PermissionSet())),
|
||||||
|
|
||||||
|
// Assume no parent groups if group cannot be found
|
||||||
|
parentGroups:
|
||||||
|
membershipService.getUserGroups(dataSource, identifier, true)
|
||||||
|
['catch'](requestService.defaultValue([])),
|
||||||
|
|
||||||
|
// Assume no member groups if group cannot be found
|
||||||
|
memberGroups:
|
||||||
|
membershipService.getMemberUserGroups(dataSource, identifier)
|
||||||
|
['catch'](requestService.defaultValue([])),
|
||||||
|
|
||||||
|
// Assume no member users if group cannot be found
|
||||||
|
memberUsers:
|
||||||
|
membershipService.getMemberUsers(dataSource, identifier)
|
||||||
|
['catch'](requestService.defaultValue([]))
|
||||||
|
|
||||||
})
|
})
|
||||||
.then(function userGroupDataRetrieved(values) {
|
.then(function userGroupDataRetrieved(values) {
|
||||||
|
|
||||||
$scope.userGroups = values.userGroups;
|
$scope.userGroups = values.userGroups;
|
||||||
$scope.userGroup = values.userGroups[dataSource];
|
|
||||||
$scope.parentGroups = values.parentGroups;
|
$scope.parentGroups = values.parentGroups;
|
||||||
$scope.memberGroups = values.memberGroups;
|
$scope.memberGroups = values.memberGroups;
|
||||||
$scope.memberUsers = values.memberUsers;
|
$scope.memberUsers = values.memberUsers;
|
||||||
|
|
||||||
// Create skeleton user group if user group does not exist
|
// Create skeleton user group if user group does not exist
|
||||||
if (!$scope.userGroup)
|
$scope.userGroup = values.userGroups[dataSource] || new UserGroup({
|
||||||
$scope.userGroup = new UserGroup({
|
'identifier' : identifier
|
||||||
'identifier' : identifier
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$scope.permissionFlags = PermissionFlagSet.fromPermissionSet(values.permissions);
|
$scope.permissionFlags = PermissionFlagSet.fromPermissionSet(values.permissions);
|
||||||
|
|
||||||
|
@@ -91,6 +91,33 @@ angular.module('rest').factory('requestService', ['$injector',
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a promise error callback which resolves the promise with the
|
||||||
|
* given default value only if the @link{Error} in the original rejection
|
||||||
|
* is a NOT_FOUND error. All other errors are passed through and must be
|
||||||
|
* handled as yet more rejections.
|
||||||
|
*
|
||||||
|
* @param {*} value
|
||||||
|
* The default value to use to resolve the promise if the promise is
|
||||||
|
* rejected with a NOT_FOUND error.
|
||||||
|
*
|
||||||
|
* @returns {Function}
|
||||||
|
* A function which can be provided as the error callback for a
|
||||||
|
* promise.
|
||||||
|
*/
|
||||||
|
service.defaultValue = function defaultValue(value) {
|
||||||
|
return service.createErrorCallback(function resolveIfNotFound(error) {
|
||||||
|
|
||||||
|
// Return default value only if not found
|
||||||
|
if (error.type === Error.Type.NOT_FOUND)
|
||||||
|
return value;
|
||||||
|
|
||||||
|
// Reject promise with original error otherwise
|
||||||
|
throw error;
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Promise error callback which ignores all rejections due to REST errors,
|
* Promise error callback which ignores all rejections due to REST errors,
|
||||||
* but logs all other rejections, such as those due to JavaScript errors.
|
* but logs all other rejections, such as those due to JavaScript errors.
|
||||||
|
Reference in New Issue
Block a user