From 529e19729bc03f0973d876f85d20f5c54c4815a3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 13 Jun 2021 21:27:48 -0700 Subject: [PATCH] GUACAMOLE-680: Ensure the "guacLogout" event is specific to manual logouts. --- .../app/auth/service/authenticationService.js | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/guacamole/src/main/frontend/src/app/auth/service/authenticationService.js b/guacamole/src/main/frontend/src/app/auth/service/authenticationService.js index d05a0d38c..16e781713 100644 --- a/guacamole/src/main/frontend/src/app/auth/service/authenticationService.js +++ b/guacamole/src/main/frontend/src/app/auth/service/authenticationService.js @@ -175,7 +175,7 @@ angular.module('auth').factory('authenticationService', ['$injector', // If an old token existed, request that the token be revoked if (currentToken) { - service.logout().catch(angular.noop) + service.revokeToken(currentToken).catch(angular.noop); } // Notify of login and new token @@ -252,6 +252,24 @@ angular.module('auth').factory('authenticationService', ['$injector', }; + /** + * Makes a request to revoke an authentication token using the token REST + * API endpoint, returning a promise succeeds only if the token was + * successfully revoked. + * + * @param {string} token + * The authentication token to revoke. + * + * @returns {Promise} + * A promise which succeeds only if the token was successfully revoked. + */ + service.revokeToken = function revokeToken(token) { + return requestService({ + method: 'DELETE', + url: 'api/tokens/' + token + }); + }; + /** * Makes a request to authenticate a user using the token REST API endpoint * with a username and password, ignoring any currently-stored token, @@ -276,7 +294,7 @@ angular.module('auth').factory('authenticationService', ['$injector', }; /** - * Makes a request to logout a user using the login REST API endpoint, + * Makes a request to logout a user using the token REST API endpoint, * returning a promise succeeds only if the logout operation was * successful. * @@ -294,10 +312,7 @@ angular.module('auth').factory('authenticationService', ['$injector', $rootScope.$broadcast('guacLogout', token); // Delete old token - return requestService({ - method: 'DELETE', - url: 'api/tokens/' + token - }); + return service.revokeToken(token); };