diff options
author | Waqas Hussain <waqas20@gmail.com> | 2010-06-13 18:14:46 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2010-06-13 18:14:46 +0500 |
commit | 47ff98b7415a5f9cc3648f4cfb04bd79b3987c9a (patch) | |
tree | 70168949ffca4890174afaa46a8c33d33376a7a1 /plugins | |
parent | 56973dec5cac985f010148029df0195cda8218db (diff) | |
download | prosody-47ff98b7415a5f9cc3648f4cfb04bd79b3987c9a.tar.gz prosody-47ff98b7415a5f9cc3648f4cfb04bd79b3987c9a.zip |
MUC: Added password checking on room join.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/muc/muc.lib.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 813a071c..69b01336 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -337,7 +337,15 @@ function room_mt:handle_to_occupant(origin, stanza) -- PM, vCards, etc end is_merge = true; end - if not new_nick then + local password = stanza:get_child("x", "http://jabber.org/protocol/muc"); + password = password and password:get_child("password", "http://jabber.org/protocol/muc"); + password = password and password[1] ~= "" and password[1]; + if self:get_password() and self:get_password() ~= password then + log("debug", "%s couldn't join due to invalid password: %s", from, to); + local reply = st.error_reply(stanza, "auth", "not-authorized"):up(); + reply.tags[1].attr.code = "401"; + origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"})); + elseif not new_nick then log("debug", "%s couldn't join due to nick conflict: %s", from, to); local reply = st.error_reply(stanza, "cancel", "conflict"):up(); reply.tags[1].attr.code = "409"; |