The Lua files contain lots of the following code in various versions:
canUse = false
if account then
local lid = doc.list_raw:match("<[^.]+%.(.-)>")
local flid = doc.list_raw:match("<([^.]+%..-)>")
for k, v in pairs(rights or {}) do
if v == "*" or v == lid or v == flid then
canUse = true
break
end
end
end
Seems to me that this code should be standardised and centralised.
For example, the API could be:
function checkAccess(r, doc, account, rights)
-- account: if not provided, will be fetched from lib/user
-- rights: if not provided, will be fetched from lib/aaa
-- returns true/false
However I'm not sure if there is an existing library module which is
suitable, so I think it would be better to create a new one.
Thoughts?