Comparison

plugins/muc/muc.lib.lua @ 3245:a8a4c87a4fbf

MUC: Added password checking on room join.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 13 Jun 2010 18:14:46 +0500
parent 3244:616a3bb2bad9
child 3246:3371419eb0e1
comparison
equal deleted inserted replaced
3244:616a3bb2bad9 3245:a8a4c87a4fbf
335 if jid_bare(from) ~= jid_bare(self._occupants[to].jid) then 335 if jid_bare(from) ~= jid_bare(self._occupants[to].jid) then
336 new_nick = nil; 336 new_nick = nil;
337 end 337 end
338 is_merge = true; 338 is_merge = true;
339 end 339 end
340 if not new_nick then 340 local password = stanza:get_child("x", "http://jabber.org/protocol/muc");
341 password = password and password:get_child("password", "http://jabber.org/protocol/muc");
342 password = password and password[1] ~= "" and password[1];
343 if self:get_password() and self:get_password() ~= password then
344 log("debug", "%s couldn't join due to invalid password: %s", from, to);
345 local reply = st.error_reply(stanza, "auth", "not-authorized"):up();
346 reply.tags[1].attr.code = "401";
347 origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"}));
348 elseif not new_nick then
341 log("debug", "%s couldn't join due to nick conflict: %s", from, to); 349 log("debug", "%s couldn't join due to nick conflict: %s", from, to);
342 local reply = st.error_reply(stanza, "cancel", "conflict"):up(); 350 local reply = st.error_reply(stanza, "cancel", "conflict"):up();
343 reply.tags[1].attr.code = "409"; 351 reply.tags[1].attr.code = "409";
344 origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"})); 352 origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"}));
345 else 353 else