grim/prosody_mod_auth_jetbrains_hub

Parents 951359d77b5f
Children acb40e1d5fac
Use table.concat rather than the giant for loop of doom that we originally had
--- a/mod_auth_jetbrains_hub.lua Sun Nov 03 03:45:47 2019 -0600
+++ b/mod_auth_jetbrains_hub.lua Sun Nov 03 04:01:02 2019 -0600
@@ -39,23 +39,11 @@
return ""
end
- -- we have at least one group, so output the start of our query
- local query = " and ("
-
- for i, v in ipairs(hub_groups) do
- -- add the group making sure to quote it as spaces are allowed and will
- -- fail if they're not quoted.
- query = query .. "in:\"" .. v .. "\""
-
- -- if we have additional groups add our "or" separator between the
- -- groups.
- if i < #hub_groups then
- query = query .. " or "
- end
- end
-
- -- finally add our closing paren and return the query
- return query .. ")"
+ -- we have at least one group, so build the query that checks that the user
+ -- is in at least one of the groups. For example, if we groups was set to
+ -- {"admins", "users"} the results of this would be:
+ -- ' and (in:"admins" or in:"users")'
+ return " and (in:\"" .. table.concat(hub_groups, " or ") .. "\")"
end
local group_query = get_group_query()