mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUAC-932: Explicitly handle lack of auth data. Document return values for such a case.
This commit is contained in:
@@ -71,24 +71,43 @@ angular.module('auth').factory('authenticationService', ['$http', '$cookieStore'
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the user ID of the current user.
|
* Returns the user ID of the current user. If the current user is not
|
||||||
|
* logged in, this ID may not be valid.
|
||||||
*
|
*
|
||||||
* @returns {String} The user ID of the current user.
|
* @returns {String}
|
||||||
|
* The user ID of the current user, or null if no authentication data
|
||||||
|
* is present.
|
||||||
*/
|
*/
|
||||||
service.getCurrentUserID = function getCurrentUserID() {
|
service.getCurrentUserID = function getCurrentUserID() {
|
||||||
|
|
||||||
|
// Return user ID, if available
|
||||||
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
||||||
return authData && authData.userID;
|
if (authData)
|
||||||
|
return authData.userID;
|
||||||
|
|
||||||
|
// No auth data present
|
||||||
|
return null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the auth token associated with the current user. If the current
|
* Returns the auth token associated with the current user. If the current
|
||||||
* user is not logged in, this token may not be valid.
|
* user is not logged in, this token may not be valid.
|
||||||
*
|
*
|
||||||
* @returns {String} The auth token associated with the current user.
|
* @returns {String}
|
||||||
|
* The auth token associated with the current user, or null if no
|
||||||
|
* authentication data is present.
|
||||||
*/
|
*/
|
||||||
service.getCurrentToken = function getCurrentToken() {
|
service.getCurrentToken = function getCurrentToken() {
|
||||||
|
|
||||||
|
// Return auth token, if available
|
||||||
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
var authData = $cookieStore.get(AUTH_COOKIE_ID);
|
||||||
return authData && authData.authToken;
|
if (authData)
|
||||||
|
return authData.authToken;
|
||||||
|
|
||||||
|
// No auth data present
|
||||||
|
return null;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
|
Reference in New Issue
Block a user