diff options
author | Kim Alvefur <zash@zash.se> | 2019-11-16 16:52:31 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-11-16 16:52:31 +0100 |
commit | 908f5b61c55e4cba39e61ac415b0fca384a1095d (patch) | |
tree | 6e391ff6608608f181e42c92ee6dfd7c534da255 /plugins/muc/register.lib.lua | |
parent | c4c38d2f01d5f2711b527c7c2412250ed6c58738 (diff) | |
parent | fd9ccf20d5b652dbad1f37cecd540661f4642ee6 (diff) | |
download | prosody-908f5b61c55e4cba39e61ac415b0fca384a1095d.tar.gz prosody-908f5b61c55e4cba39e61ac415b0fca384a1095d.zip |
Merge 0.11->trunk
Diffstat (limited to 'plugins/muc/register.lib.lua')
-rw-r--r-- | plugins/muc/register.lib.lua | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/plugins/muc/register.lib.lua b/plugins/muc/register.lib.lua index 95ed1a84..bf8cd877 100644 --- a/plugins/muc/register.lib.lua +++ b/plugins/muc/register.lib.lua @@ -15,8 +15,7 @@ local function get_reserved_nicks(room) end module:log("debug", "Refreshing reserved nicks..."); local reserved_nicks = {}; - for jid in room:each_affiliation() do - local data = room._affiliation_data[jid]; + for jid, _, data in room:each_affiliation() do local nick = data and data.reserved_nickname; module:log("debug", "Refreshed for %s: %s", jid, nick); if nick then @@ -54,7 +53,7 @@ end); local registration_form = dataforms.new { { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/muc#register" }, - { name = "muc#register_roomnick", type = "text-single", label = "Nickname"}, + { name = "muc#register_roomnick", type = "text-single", required = true, label = "Nickname"}, }; local function enforce_nick_policy(event) @@ -135,7 +134,19 @@ local function handle_register_iq(room, origin, stanza) return true; end local form_tag = query:get_child("x", "jabber:x:data"); - local reg_data = form_tag and registration_form:data(form_tag); + if not form_tag then + origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing dataform")); + return true; + end + local form_type, err = dataforms.get_type(form_tag); + if not form_type then + origin.send(st.error_reply(stanza, "modify", "bad-request", "Error with form: "..err)); + return true; + elseif form_type ~= "http://jabber.org/protocol/muc#register" then + origin.send(st.error_reply(stanza, "modify", "bad-request", "Error in form")); + return true; + end + local reg_data = registration_form:data(form_tag); if not reg_data then origin.send(st.error_reply(stanza, "modify", "bad-request", "Error in form")); return true; |