mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
storage.js: Prevent conflicts with other apps accessing the same storage
This commit is contained in:
parent
0f16e20d92
commit
2ac848828a
@ -53,11 +53,12 @@
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
prefixKey: function(key) {
|
prefixKey: function(key) {
|
||||||
|
var prefix = 'icinga.';
|
||||||
if (typeof this.prefix !== 'undefined') {
|
if (typeof this.prefix !== 'undefined') {
|
||||||
return this.prefix + '.' + key;
|
prefix = prefix + this.prefix + '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
return prefix + key;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,6 +114,13 @@
|
|||||||
* @param {StorageEvent} event
|
* @param {StorageEvent} event
|
||||||
*/
|
*/
|
||||||
onStorage: function(event) {
|
onStorage: function(event) {
|
||||||
|
var url = icinga.utils.parseUrl(event.url);
|
||||||
|
if (! url.path.startsWith(icinga.config.baseUrl)) {
|
||||||
|
// A localStorage is shared between all paths on the same origin.
|
||||||
|
// So we need to make sure it's us who made a change.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof this.subscribers[event.key] !== 'undefined') {
|
if (typeof this.subscribers[event.key] !== 'undefined') {
|
||||||
var subscriber = this.subscribers[event.key];
|
var subscriber = this.subscribers[event.key];
|
||||||
subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event);
|
subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user