comparison plugins/muc/register.lib.lua @ 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 9eee04a95a25
children 356c8ec22e9a
comparison
equal deleted inserted replaced
13906:0749265327d2 13907:827a4cfd3fad
123 local user_jid = jid_bare(stanza.attr.from) 123 local user_jid = jid_bare(stanza.attr.from)
124 local affiliation = room:get_affiliation(user_jid); 124 local affiliation = room:get_affiliation(user_jid);
125 if affiliation == "outcast" then 125 if affiliation == "outcast" then
126 origin.send(st.error_reply(stanza, "auth", "forbidden")); 126 origin.send(st.error_reply(stanza, "auth", "forbidden"));
127 return true; 127 return true;
128 elseif not (affiliation or allow_unaffiliated) then 128 elseif not affiliation then
129 origin.send(st.error_reply(stanza, "auth", "registration-required")); 129 if room:get_members_only() then
130 return true; 130 -- Never allow unaffiliated users to register their way into a members-only room
131 origin.send(st.error_reply(stanza, "auth", "forbidden"));
132 return true;
133 elseif not allow_unaffiliated then
134 -- Not members-only, but we're not permitting registration due to config
135 origin.send(st.error_reply(stanza, "auth", "registration-required"));
136 return true;
137 end
131 end 138 end
132 local reply = st.reply(stanza); 139 local reply = st.reply(stanza);
133 local registered_nick = get_registered_nick(room, user_jid); 140 local registered_nick = get_registered_nick(room, user_jid);
134 if stanza.attr.type == "get" then 141 if stanza.attr.type == "get" then
135 reply:query("jabber:iq:register"); 142 reply:query("jabber:iq:register");