luci-base: tie cached system features to user session

Store the cached system feature flags keyed by the current session id,
this ensures that the features are refreshed on login.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2019-09-21 10:55:54 +02:00
parent 119c6319cb
commit 6dba41cadc

View file

@ -823,9 +823,14 @@
}, },
probeSystemFeatures: function() { probeSystemFeatures: function() {
var sessionid = classes.rpc.getSessionID();
if (sysFeatures == null) { if (sysFeatures == null) {
try { try {
sysFeatures = JSON.parse(window.sessionStorage.getItem('sysFeatures')); var data = JSON.parse(window.sessionStorage.getItem('sysFeatures'));
if (this.isObject(data) && this.isObject(data[sessionid]))
sysFeatures = data[sessionid];
} }
catch (e) {} catch (e) {}
} }
@ -837,7 +842,10 @@
expect: { '': {} } expect: { '': {} }
})().then(function(features) { })().then(function(features) {
try { try {
window.sessionStorage.setItem('sysFeatures', JSON.stringify(features)); var data = {};
data[sessionid] = features;
window.sessionStorage.setItem('sysFeatures', JSON.stringify(data));
} }
catch (e) {} catch (e) {}