Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 6136:2068242028ff
plugins/muc/muc.lib: Better password check
| author | daurnimator <quae@daurnimator.com> |
|---|---|
| date | Mon, 24 Mar 2014 12:44:31 -0400 |
| parents | 6b061f8c6e11 |
| children | 7db24f237a83 |
comparison
equal
deleted
inserted
replaced
| 6135:6b061f8c6e11 | 6136:2068242028ff |
|---|---|
| 478 | 478 |
| 479 module:hook("muc-occupant-pre-join/password", function(event) | 479 module:hook("muc-occupant-pre-join/password", function(event) |
| 480 local room, stanza = event.room, event.stanza; | 480 local room, stanza = event.room, event.stanza; |
| 481 local from, to = stanza.attr.from, stanza.attr.to; | 481 local from, to = stanza.attr.from, stanza.attr.to; |
| 482 local password = stanza:get_child("x", "http://jabber.org/protocol/muc"); | 482 local password = stanza:get_child("x", "http://jabber.org/protocol/muc"); |
| 483 password = password and password:get_child("password", "http://jabber.org/protocol/muc"); | 483 password = password and password:get_child_text("password", "http://jabber.org/protocol/muc"); |
| 484 password = password and password[1] ~= "" and password[1]; | 484 if not password or password == "" then password = nil; end |
| 485 if room:get_password() and room:get_password() ~= password then | 485 if room:get_password() ~= password then |
| 486 local from, to = stanza.attr.from, stanza.attr.to; | 486 local from, to = stanza.attr.from, stanza.attr.to; |
| 487 log("debug", "%s couldn't join due to invalid password: %s", from, to); | 487 log("debug", "%s couldn't join due to invalid password: %s", from, to); |
| 488 local reply = st.error_reply(stanza, "auth", "not-authorized"):up(); | 488 local reply = st.error_reply(stanza, "auth", "not-authorized"):up(); |
| 489 reply.tags[1].attr.code = "401"; | 489 reply.tags[1].attr.code = "401"; |
| 490 event.origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"})); | 490 event.origin.send(reply:tag("x", {xmlns = "http://jabber.org/protocol/muc"})); |
