summaryrefslogtreecommitdiff
path: root/luci2
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2014-01-31 21:30:08 +0000
committerJo-Philipp Wich <jow@openwrt.org>2014-01-31 21:30:08 +0000
commit5627975f94aaea2d2933bbbc4020a73d052c3ad0 (patch)
tree9c85d127aeab235fda5f58d481c83c3739936d34 /luci2
parentd8c74245a6d23cdff704dc2b36c05d1bf236fdf0 (diff)
downloadluci2-ui-5627975f94aaea2d2933bbbc4020a73d052c3ad0.tar.gz
luci2: implement LuCI2.session.updateACLs() and LuCI2.session.hasACL()
Diffstat (limited to 'luci2')
-rw-r--r--luci2/htdocs/luci2/luci2.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js
index c4dbbd6..58d38df 100644
--- a/luci2/htdocs/luci2/luci2.js
+++ b/luci2/htdocs/luci2/luci2.js
@@ -2205,6 +2205,41 @@ function LuCI2()
window.clearInterval(this._hearbeatInterval);
delete this._hearbeatInterval;
}
+ },
+
+
+ _acls: { },
+
+ _fetch_acls: _luci2.rpc.declare({
+ object: 'session',
+ method: 'access',
+ expect: { '': { } }
+ }),
+
+ _fetch_acls_cb: function(acls)
+ {
+ _luci2.session._acls = acls;
+ },
+
+ updateACLs: function()
+ {
+ return _luci2.session._fetch_acls()
+ .then(_luci2.session._fetch_acls_cb);
+ },
+
+ hasACL: function(scope, object, func)
+ {
+ var acls = _luci2.session._acls;
+
+ if (typeof(func) == 'undefined')
+ return (acls && acls[scope] && acls[scope][object]);
+
+ if (acls && acls[scope] && acls[scope][object])
+ for (var i = 0; i < acls[scope][object].length; i++)
+ if (acls[scope][object][i] == func)
+ return true;
+
+ return false;
}
};