From 6dba41cadc82785f23773f219d30403f6b12956e Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 21 Sep 2019 10:55:54 +0200 Subject: [PATCH] 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 --- .../luci-base/htdocs/luci-static/resources/luci.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 1d349ebc17..4e3c8445a9 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -823,9 +823,14 @@ }, probeSystemFeatures: function() { + var sessionid = classes.rpc.getSessionID(); + if (sysFeatures == null) { 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) {} } @@ -837,7 +842,10 @@ expect: { '': {} } })().then(function(features) { try { - window.sessionStorage.setItem('sysFeatures', JSON.stringify(features)); + var data = {}; + data[sessionid] = features; + + window.sessionStorage.setItem('sysFeatures', JSON.stringify(data)); } catch (e) {} -- 2.30.2