luci-base: tie cached system features to user session
authorJo-Philipp Wich <jo@mein.io>
Sat, 21 Sep 2019 08:55:54 +0000 (10:55 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sat, 21 Sep 2019 08:55:54 +0000 (10:55 +0200)
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>
modules/luci-base/htdocs/luci-static/resources/luci.js

index 1d349ebc1735e26278a489fd846c6d39b1e7f95c..4e3c8445a94dc0013a20708e4744f622e7c9c951 100644 (file)
                },
 
                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) {}
                        }
                                        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) {}