# HG changeset patch # User Waqas Hussain # Date 1276434886 -18000 # Node ID a8a4c87a4fbf39d71958ea39101b051a7b8d0232 # Parent 616a3bb2bad9ebb4ae0d18c0a52b4adbd76fee7f MUC: Added password checking on room join. diff -r 616a3bb2bad9 -r a8a4c87a4fbf plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Sun Jun 13 18:13:18 2010 +0500 +++ b/plugins/muc/muc.lib.lua Sun Jun 13 18:14:46 2010 +0500 @@ -337,7 +337,15 @@ 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";