From 0b92ad59ee8bdb587fd1e9dfc307f739b4b3f04a Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Wed, 8 Apr 2015 22:53:44 -0700 Subject: [PATCH] GUAC-1126 Clear caches on logout. --- .../src/main/webapp/app/auth/authModule.js | 2 +- .../app/auth/service/authenticationService.js | 4 ++ .../webapp/app/rest/services/cacheService.js | 52 +++++++++++-------- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/guacamole/src/main/webapp/app/auth/authModule.js b/guacamole/src/main/webapp/app/auth/authModule.js index f3f565798..2ac7de1ef 100644 --- a/guacamole/src/main/webapp/app/auth/authModule.js +++ b/guacamole/src/main/webapp/app/auth/authModule.js @@ -23,4 +23,4 @@ /** * The module for authentication and management of tokens. */ -angular.module('auth', ['ngCookies']); +angular.module('auth', ['ngCookies', 'rest']); diff --git a/guacamole/src/main/webapp/app/auth/service/authenticationService.js b/guacamole/src/main/webapp/app/auth/service/authenticationService.js index c98b36bcc..1909a7b06 100644 --- a/guacamole/src/main/webapp/app/auth/service/authenticationService.js +++ b/guacamole/src/main/webapp/app/auth/service/authenticationService.js @@ -30,6 +30,7 @@ angular.module('auth').factory('authenticationService', ['$injector', var $cookieStore = $injector.get('$cookieStore'); var $http = $injector.get('$http'); var $q = $injector.get('$q'); + var cacheService = $injector.get('cacheService'); var service = {}; @@ -193,6 +194,9 @@ angular.module('auth').factory('authenticationService', ['$injector', * successful. */ service.logout = function logout() { + + // Clear all caches + cacheService.clearCaches(); // Clear authentication data var token = service.getCurrentToken(); diff --git a/guacamole/src/main/webapp/app/rest/services/cacheService.js b/guacamole/src/main/webapp/app/rest/services/cacheService.js index be4facfec..16b7b567a 100644 --- a/guacamole/src/main/webapp/app/rest/services/cacheService.js +++ b/guacamole/src/main/webapp/app/rest/services/cacheService.js @@ -28,32 +28,42 @@ angular.module('rest').factory('cacheService', ['$injector', // Required services var $cacheFactory = $injector.get('$cacheFactory'); + - // Return service containing all caches - return { + // Service containing all caches + var service = {}; - /** - * Shared cache used by both connectionGroupService and - * connectionService. - * - * @type $cacheFactory.Cache - */ - connections : $cacheFactory('API-CONNECTIONS'), + /** + * Shared cache used by both connectionGroupService and + * connectionService. + * + * @type $cacheFactory.Cache + */ + service.connections = $cacheFactory('API-CONNECTIONS'); - /** - * Cache used by protocolService. - * - * @type $cacheFactory.Cache - */ - protocols : $cacheFactory('API-PROTOCOLS'), + /** + * Cache used by protocolService. + * + * @type $cacheFactory.Cache + */ + service.protocols = $cacheFactory('API-PROTOCOLS'); - /** - * Shared cache used by both userService and permissionService. - * - * @type $cacheFactory.Cache - */ - users : $cacheFactory('API-USERS') + /** + * Shared cache used by both userService and permissionService. + * + * @type $cacheFactory.Cache + */ + service.users = $cacheFactory('API-USERS'); + /** + * Clear all caches defined in this service. + */ + service.clearCaches = function clearCaches() { + service.protocols.removeAll(); + service.connections.removeAll(); + service.users.removeAll(); }; + + return service; }]);