# HG changeset patch # User Seve Ferrer # Date 1608305461 -3600 # Node ID aec8148df26a6154b4021a2a032389b82a00e178 # Parent d261233f7cedf384a3697b42533473eba13ff49b mod_muc_http_auth: Bugfix: Not properly listening on register IQs diff -r d261233f7ced -r aec8148df26a mod_muc_http_auth/mod_muc_http_auth.lua --- a/mod_muc_http_auth/mod_muc_http_auth.lua Fri Dec 18 15:28:12 2020 +0100 +++ b/mod_muc_http_auth/mod_muc_http_auth.lua Fri Dec 18 16:31:01 2020 +0100 @@ -11,6 +11,8 @@ local insecure = module:get_option("muc_http_auth_insecure", false) --For development purposes local authorize_registration = module:get_option("muc_http_auth_authorize_registration", false) +local verbs = {presence='join', iq='register'}; + local function must_be_authorized(room_node) -- If none of these is set, all rooms need authorization if not enabled_for and not disabled_for then return true; end @@ -35,9 +37,7 @@ local function handle_presence(event) local stanza = event.stanza; - if stanza.name ~= "presence" or stanza.attr.type == "unavailable" then - return; - end + if stanza.name ~= "iq" and stanza.name ~= "presence" or stanza.attr.type == "unavailable" then return; end local room, origin = event.room, event.origin; if (not room) or (not origin) then return; end @@ -50,15 +50,16 @@ local result = wait_for(http.request(url, {method="GET", insecure=insecure}):next(handle_success, handle_error)); local response, err = result.response, result.err; + local verb = verbs[stanza.name]; if not (response and response.allowed) then -- User is not authorized to join this room err = (response or {}).err or err - module:log("debug", user_bare_jid .. " is not authorized to join " .. room.jid .. " Error: " .. tostring(err)); + module:log("debug", user_bare_jid .. " is not authorized to " ..verb.. ": " .. room.jid .. " Error: " .. tostring(err)); origin.send(st.error_reply(stanza, "error", "not-authorized", nil, module.host)); return true; end - module:log("debug", user_bare_jid .. " is authorized to join " .. room.jid); + module:log("debug", user_bare_jid .. " is authorized to " .. verb .. ": " .. room.jid); return; end