mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-932: Clean up auth service. Change token service path to /api/tokens.
This commit is contained in:
@@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*
|
*
|
||||||
* @author James Muehlner
|
* @author James Muehlner
|
||||||
*/
|
*/
|
||||||
@Path("/token")
|
@Path("/tokens")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public class TokenRESTService {
|
public class TokenRESTService {
|
||||||
|
|
||||||
|
@@ -28,20 +28,33 @@ angular.module('auth').factory('authenticationService', ['$http', '$cookieStore'
|
|||||||
|
|
||||||
var service = {};
|
var service = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The unique identifier of the local cookie which stores the user's
|
||||||
|
* current authentication token and user ID.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
var AUTH_COOKIE_ID = "GUAC_AUTH";
|
var AUTH_COOKIE_ID = "GUAC_AUTH";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a request to authenticate a user using the token REST API endpoint,
|
* Makes a request to authenticate a user using the token REST API endpoint,
|
||||||
* returning a promise that can be used for processing the results of the call.
|
* returning a promise that succeeds only if the login operation was
|
||||||
|
* successful. The resulting authentication data can be retrieved later
|
||||||
|
* via getCurrentToken() or getCurrentUserID().
|
||||||
*
|
*
|
||||||
* @param {String} username The username to log in with.
|
* @param {String} username
|
||||||
* @param {String} password The password to log in with.
|
* The username to log in with.
|
||||||
* @returns {Promise} A promise for the HTTP call.
|
*
|
||||||
|
* @param {String} password
|
||||||
|
* The password to log in with.
|
||||||
|
*
|
||||||
|
* @returns {Promise}
|
||||||
|
* A promise which succeeds only if the login operation was successful.
|
||||||
*/
|
*/
|
||||||
service.login = function login(username, password) {
|
service.login = function login(username, password) {
|
||||||
return $http({
|
return $http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: 'api/token',
|
url: 'api/tokens',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
},
|
},
|
||||||
@@ -59,14 +72,17 @@ angular.module('auth').factory('authenticationService', ['$http', '$cookieStore'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a request to logout a user using the login REST API endpoint,
|
* Makes a request to logout a user using the login REST API endpoint,
|
||||||
* returning a promise that can be used for processing the results of the call.
|
* returning a promise succeeds only if the logout operation was
|
||||||
|
* successful.
|
||||||
*
|
*
|
||||||
* @returns {Promise} A promise for the HTTP call.
|
* @returns {Promise}
|
||||||
|
* A promise which succeeds only if the logout operation was
|
||||||
|
* successful.
|
||||||
*/
|
*/
|
||||||
service.logout = function logout() {
|
service.logout = function logout() {
|
||||||
return $http({
|
return $http({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: 'api/token/' + encodeURIComponent(service.getCurrentToken())
|
url: 'api/tokens/' + encodeURIComponent(service.getCurrentToken())
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user