mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-09 22:51:22 +00:00
GUAC-586: Clarify auth result and include data source. Consistently refer to usernames as "username", not "user IDs".
This commit is contained in:
@@ -57,7 +57,7 @@ angular.module('auth').factory('authenticationService', ['$injector',
|
||||
|
||||
/**
|
||||
* The unique identifier of the local cookie which stores the user's
|
||||
* current authentication token and user ID.
|
||||
* current authentication token and username.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
@@ -68,7 +68,7 @@ angular.module('auth').factory('authenticationService', ['$injector',
|
||||
* and given arbitrary parameters, returning a promise that succeeds only
|
||||
* if the authentication operation was successful. The resulting
|
||||
* authentication data can be retrieved later via getCurrentToken() or
|
||||
* getCurrentUserID().
|
||||
* getCurrentUsername().
|
||||
*
|
||||
* The provided parameters can be virtually any object, as each property
|
||||
* will be sent as an HTTP parameter in the authentication request.
|
||||
@@ -99,8 +99,9 @@ angular.module('auth').factory('authenticationService', ['$injector',
|
||||
|
||||
// Store auth data
|
||||
$cookieStore.put(AUTH_COOKIE_ID, {
|
||||
authToken : data.authToken,
|
||||
userID : data.userID
|
||||
authToken : data.authToken,
|
||||
username : data.username,
|
||||
dataSource : data.dataSource
|
||||
});
|
||||
|
||||
// Process is complete
|
||||
@@ -174,7 +175,7 @@ angular.module('auth').factory('authenticationService', ['$injector',
|
||||
* its properties will be included as parameters in the update request.
|
||||
* This function returns a promise that succeeds only if the authentication
|
||||
* operation was successful. The resulting authentication data can be
|
||||
* retrieved later via getCurrentToken() or getCurrentUserID().
|
||||
* retrieved later via getCurrentToken() or getCurrentUsername().
|
||||
*
|
||||
* If there is no current auth token, this function behaves identically to
|
||||
* authenticate(), and makes a general authentication request.
|
||||
@@ -209,7 +210,7 @@ angular.module('auth').factory('authenticationService', ['$injector',
|
||||
* with a username and password, ignoring any currently-stored token,
|
||||
* returning a promise that succeeds only if the login operation was
|
||||
* successful. The resulting authentication data can be retrieved later
|
||||
* via getCurrentToken() or getCurrentUserID().
|
||||
* via getCurrentToken() or getCurrentUsername().
|
||||
*
|
||||
* @param {String} username
|
||||
* The username to log in with.
|
||||
@@ -254,19 +255,19 @@ angular.module('auth').factory('authenticationService', ['$injector',
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the user ID of the current user. If the current user is not
|
||||
* logged in, this ID may not be valid.
|
||||
* Returns the username of the current user. If the current user is not
|
||||
* logged in, this value may not be valid.
|
||||
*
|
||||
* @returns {String}
|
||||
* The user ID of the current user, or null if no authentication data
|
||||
* The username of the current user, or null if no authentication data
|
||||
* is present.
|
||||
*/
|
||||
service.getCurrentUserID = function getCurrentUserID() {
|
||||
service.getCurrentUsername = function getCurrentUsername() {
|
||||
|
||||
// Return user ID, if available
|
||||
// Return username, if available
|
||||
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
||||
if (authData)
|
||||
return authData.userID;
|
||||
return authData.username;
|
||||
|
||||
// No auth data present
|
||||
return null;
|
||||
@@ -293,5 +294,45 @@ angular.module('auth').factory('authenticationService', ['$injector',
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the identifier of the data source that authenticated the current
|
||||
* user. If the current user is not logged in, this value may not be valid.
|
||||
*
|
||||
* @returns {String}
|
||||
* The identifier of the data source that authenticated the current
|
||||
* user, or null if no authentication data is present.
|
||||
*/
|
||||
service.getDataSource = function getDataSource() {
|
||||
|
||||
// Return data source, if available
|
||||
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
||||
if (authData)
|
||||
return authData.dataSource;
|
||||
|
||||
// No auth data present
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the identifiers of all data sources available to the current
|
||||
* user. If the current user is not logged in, this value may not be valid.
|
||||
*
|
||||
* @returns {String[]}
|
||||
* The identifiers of all data sources availble to the current user,
|
||||
* or null if no authentication data is present.
|
||||
*/
|
||||
service.getAvailableDataSources = function getAvailableDataSources() {
|
||||
|
||||
// Return data sources, if available
|
||||
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
||||
if (authData)
|
||||
return authData.availableDataSources;
|
||||
|
||||
// No auth data present
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
return service;
|
||||
}]);
|
||||
|
@@ -190,7 +190,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i
|
||||
});
|
||||
|
||||
// Query the user's permissions for the current connection
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
permissionService.getPermissions(authenticationService.getCurrentUsername())
|
||||
.success(function permissionsReceived(permissions) {
|
||||
|
||||
$scope.permissions = permissions;
|
||||
|
@@ -128,7 +128,7 @@ angular.module('manage').controller('manageConnectionGroupController', ['$scope'
|
||||
});
|
||||
|
||||
// Query the user's permissions for the current connection group
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
permissionService.getPermissions(authenticationService.getCurrentUsername())
|
||||
.success(function permissionsReceived(permissions) {
|
||||
|
||||
$scope.permissions = permissions;
|
||||
|
@@ -153,7 +153,7 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto
|
||||
});
|
||||
|
||||
// Query the user's permissions for the current connection
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
permissionService.getPermissions(authenticationService.getCurrentUsername())
|
||||
.success(function permissionsReceived(permissions) {
|
||||
|
||||
$scope.permissions = permissions;
|
||||
|
@@ -78,7 +78,7 @@ angular.module('navigation').directive('guacUserMenu', [function guacUserMenu()
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
$scope.username = authenticationService.getCurrentUserID();
|
||||
$scope.username = authenticationService.getCurrentUsername();
|
||||
|
||||
/**
|
||||
* The available main pages for the current user.
|
||||
|
@@ -156,7 +156,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
||||
PermissionSet.removeConnectionGroupPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, ConnectionGroup.ROOT_IDENTIFIER);
|
||||
|
||||
// Ignore permission to update self
|
||||
PermissionSet.removeUserPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, authenticationService.getCurrentUserID());
|
||||
PermissionSet.removeUserPermission(permissions, PermissionSet.ObjectPermissionType.UPDATE, authenticationService.getCurrentUsername());
|
||||
|
||||
// Determine whether the current user needs access to the user management UI
|
||||
var canManageUsers =
|
||||
@@ -247,7 +247,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
||||
|
||||
// Retrieve current permissions, resolving main pages if possible
|
||||
// Resolve promise using settings pages derived from permissions
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
permissionService.getPermissions(authenticationService.getCurrentUsername())
|
||||
.success(function permissionsRetrieved(permissions) {
|
||||
deferred.resolve(generateSettingsPages(permissions));
|
||||
});
|
||||
@@ -328,7 +328,7 @@ angular.module('navigation').factory('userPageService', ['$injector',
|
||||
});
|
||||
|
||||
// Retrieve current permissions, resolving main pages if possible
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
permissionService.getPermissions(authenticationService.getCurrentUsername())
|
||||
.success(function permissionsRetrieved(retrievedPermissions) {
|
||||
permissions = retrievedPermissions;
|
||||
resolveMainPages();
|
||||
|
@@ -48,7 +48,7 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe
|
||||
var permissionService = $injector.get('permissionService');
|
||||
|
||||
// Identifier of the current user
|
||||
var currentUserID = authenticationService.getCurrentUserID();
|
||||
var currentUsername = authenticationService.getCurrentUsername();
|
||||
|
||||
/**
|
||||
* An action to be provided along with the object sent to
|
||||
@@ -120,7 +120,7 @@ angular.module('settings').directive('guacSettingsConnections', [function guacSe
|
||||
};
|
||||
|
||||
// Retrieve current permissions
|
||||
permissionService.getPermissions(currentUserID)
|
||||
permissionService.getPermissions(currentUsername)
|
||||
.success(function permissionsRetrieved(permissions) {
|
||||
|
||||
$scope.permissions = permissions;
|
||||
|
@@ -64,7 +64,7 @@ angular.module('settings').directive('guacSettingsPreferences', [function guacSe
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
var username = authenticationService.getCurrentUserID();
|
||||
var username = authenticationService.getCurrentUsername();
|
||||
|
||||
/**
|
||||
* All currently-set preferences, or their defaults if not yet set.
|
||||
|
@@ -187,7 +187,7 @@ angular.module('settings').directive('guacSettingsSessions', [function guacSetti
|
||||
};
|
||||
|
||||
// Query the user's permissions
|
||||
permissionService.getPermissions(authenticationService.getCurrentUserID())
|
||||
permissionService.getPermissions(authenticationService.getCurrentUsername())
|
||||
.success(function permissionsReceived(retrievedPermissions) {
|
||||
$scope.permissions = retrievedPermissions;
|
||||
});
|
||||
|
@@ -48,7 +48,7 @@ angular.module('settings').directive('guacSettingsUsers', [function guacSettings
|
||||
var userService = $injector.get('userService');
|
||||
|
||||
// Identifier of the current user
|
||||
var currentUserID = authenticationService.getCurrentUserID();
|
||||
var currentUsername = authenticationService.getCurrentUsername();
|
||||
|
||||
/**
|
||||
* An action to be provided along with the object sent to
|
||||
@@ -118,7 +118,7 @@ angular.module('settings').directive('guacSettingsUsers', [function guacSettings
|
||||
};
|
||||
|
||||
// Retrieve current permissions
|
||||
permissionService.getPermissions(currentUserID)
|
||||
permissionService.getPermissions(currentUsername)
|
||||
.success(function permissionsRetrieved(permissions) {
|
||||
|
||||
$scope.permissions = permissions;
|
||||
@@ -147,7 +147,7 @@ angular.module('settings').directive('guacSettingsUsers', [function guacSettings
|
||||
|
||||
// Display only other users, not self
|
||||
$scope.users = users.filter(function isNotSelf(user) {
|
||||
return user.username !== currentUserID;
|
||||
return user.username !== currentUsername;
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user