changeset 13907:827a4cfd3fad

MUC: Don't allow self-registration into members-only MUCs when unaffiliated registration enabled
author Matthew Wild <mwild1@gmail.com>
date Thu, 26 Jun 2025 15:13:29 +0100
parents 0749265327d2
children 356c8ec22e9a
files plugins/muc/register.lib.lua
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/register.lib.lua	Thu Jun 26 14:39:45 2025 +0100
+++ b/plugins/muc/register.lib.lua	Thu Jun 26 15:13:29 2025 +0100
@@ -125,9 +125,16 @@
 	if affiliation == "outcast" then
 		origin.send(st.error_reply(stanza, "auth", "forbidden"));
 		return true;
-	elseif not (affiliation or allow_unaffiliated) then
-		origin.send(st.error_reply(stanza, "auth", "registration-required"));
-		return true;
+	elseif not affiliation then
+		if room:get_members_only() then
+			-- Never allow unaffiliated users to register their way into a members-only room
+			origin.send(st.error_reply(stanza, "auth", "forbidden"));
+			return true;
+		elseif not allow_unaffiliated then
+			-- Not members-only, but we're not permitting registration due to config
+			origin.send(st.error_reply(stanza, "auth", "registration-required"));
+			return true;
+		end
 	end
 	local reply = st.reply(stanza);
 	local registered_nick = get_registered_nick(room, user_jid);