mod_muc_http_auth/mod_muc_http_auth.lua
changeset 4305 bcb2b9adfcde
parent 4303 8006da2cf44c
child 4307 d261233f7ced
--- a/mod_muc_http_auth/mod_muc_http_auth.lua	Tue Dec 15 10:49:11 2020 +0000
+++ b/mod_muc_http_auth/mod_muc_http_auth.lua	Tue Dec 15 14:16:11 2020 +0100
@@ -12,26 +12,12 @@
 local authorize_registration = module:get_option("muc_http_auth_authorize_registration", false)
 
 local function must_be_authorized(room_node)
-	-- If none of these is set, all rooms need authorization
+	-- If none or both of these are set, all rooms need authorization
 	if not enabled_for and not disabled_for then return true; end
+	if enabled_for and disabled_for then return true; end
 
-	if enabled_for and not disabled_for then
-		for _, _room_node in ipairs(enabled_for) do
-			if _room_node == room_node then
-				return true;
-			end
-		end
-	end
-
-	if disabled_for and not enabled_for then
-		for _, _room_node in ipairs(disabled_for) do
-			if _room_node == room_node then
-				return false;
-			end
-		end
-	end
-
-	return true;
+	if enabled_for then return enabled_for:contains(room_node); end
+	if disabled_for then return not disabled_for:contains(room_node); end
 end
 
 local function handle_success(response)