diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-01-31 21:30:08 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2014-01-31 21:30:08 +0000 |
commit | 5627975f94aaea2d2933bbbc4020a73d052c3ad0 (patch) | |
tree | 9c85d127aeab235fda5f58d481c83c3739936d34 /luci2 | |
parent | d8c74245a6d23cdff704dc2b36c05d1bf236fdf0 (diff) | |
download | luci2-ui-5627975f94aaea2d2933bbbc4020a73d052c3ad0.tar.gz |
luci2: implement LuCI2.session.updateACLs() and LuCI2.session.hasACL()
Diffstat (limited to 'luci2')
-rw-r--r-- | luci2/htdocs/luci2/luci2.js | 35 |
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; } }; |