mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-08 06:01:22 +00:00
GUAC-1161: Allow custom destructor to be defined for each session-local storage.
This commit is contained in:
@@ -44,12 +44,16 @@ angular.module('storage').factory('sessionStorageFactory', ['$injector', functio
|
|||||||
* The default value for new users, or a getter which returns a newly-
|
* The default value for new users, or a getter which returns a newly-
|
||||||
* created default value.
|
* created default value.
|
||||||
*
|
*
|
||||||
|
* @param {Function} [destructor]
|
||||||
|
* Function which will be called just before the stored value is
|
||||||
|
* destroyed on logout, if a value is stored.
|
||||||
|
*
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
* A getter/setter which returns or sets the current value of the new
|
* A getter/setter which returns or sets the current value of the new
|
||||||
* session-local storage. Newly-set values will only persist of the
|
* session-local storage. Newly-set values will only persist of the
|
||||||
* user is actually logged in.
|
* user is actually logged in.
|
||||||
*/
|
*/
|
||||||
service.create = function create(template) {
|
service.create = function create(template, destructor) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether new values may be stored and retrieved.
|
* Whether new values may be stored and retrieved.
|
||||||
@@ -88,8 +92,15 @@ angular.module('storage').factory('sessionStorageFactory', ['$injector', functio
|
|||||||
|
|
||||||
// Reset value and disallow storage when the user is logged out
|
// Reset value and disallow storage when the user is logged out
|
||||||
$rootScope.$on('guacLogout', function userLoggedOut() {
|
$rootScope.$on('guacLogout', function userLoggedOut() {
|
||||||
|
|
||||||
|
// Call destructor before storage is teared down
|
||||||
|
if (angular.isDefined(value) && destructor)
|
||||||
|
destructor(value);
|
||||||
|
|
||||||
|
// Destroy storage
|
||||||
enabled = false;
|
enabled = false;
|
||||||
value = undefined;
|
value = undefined;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return getter/setter for value
|
// Return getter/setter for value
|
||||||
|
Reference in New Issue
Block a user