access.lua: move helper at the top with the other sugar stuff

This commit is contained in:
Alexandre Aubin 2023-09-29 14:30:36 +02:00
parent 99749decdc
commit cac360bee9

View file

@ -79,6 +79,19 @@ function uri_args_string(args)
return string.sub(String, 1, string.len(String) - 1) return string.sub(String, 1, string.len(String) - 1)
end end
function element_is_in_table(element, table)
if table then
for _, el in pairs(table) do
if el == element then
return true
end
end
end
return false
end
-- ########################################################################### -- ###########################################################################
-- 1. AUTHENTICATION -- 1. AUTHENTICATION
-- Check wether or not this is a logged-in user -- Check wether or not this is a logged-in user
@ -203,18 +216,6 @@ end
-- Or because the logged-in user is listed in the "users" list of the perm -- Or because the logged-in user is listed in the "users" list of the perm
-- ########################################################################### -- ###########################################################################
function element_is_in_table(element, table)
if table then
for _, el in pairs(table) do
if el == element then
return true
end
end
end
return false
end
-- No permission object found = no access -- No permission object found = no access
if permission == nil then if permission == nil then
logger:debug("No permission matching request for "..ngx.var.uri.." ... Assuming access is denied") logger:debug("No permission matching request for "..ngx.var.uri.." ... Assuming access is denied")