Mercurial > prosody-hg
comparison plugins/muc/password.lib.lua @ 9455:c62c983b8be3
MUC: Check that a room password is set before verifying password supplied by user
| author | Michel Le Bihan <michel@lebihan.pl> |
|---|---|
| date | Tue, 09 Oct 2018 18:42:19 +0200 |
| parents | 173c0e16e704 |
| children | b5fd1637f15c |
comparison
equal
deleted
inserted
replaced
| 9454:6780049be177 | 9455:c62c983b8be3 |
|---|---|
| 40 end); | 40 end); |
| 41 | 41 |
| 42 -- Don't allow anyone to join room unless they provide the password | 42 -- Don't allow anyone to join room unless they provide the password |
| 43 module:hook("muc-occupant-pre-join", function(event) | 43 module:hook("muc-occupant-pre-join", function(event) |
| 44 local room, stanza = event.room, event.stanza; | 44 local room, stanza = event.room, event.stanza; |
| 45 if not get_password(room) then return end | |
| 45 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); | 46 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); |
| 46 if not muc_x then return end | 47 if not muc_x then return end |
| 47 local password = muc_x:get_child_text("password", "http://jabber.org/protocol/muc"); | 48 local password = muc_x:get_child_text("password", "http://jabber.org/protocol/muc"); |
| 48 if not password or password == "" then password = nil; end | 49 if not password or password == "" then password = nil; end |
| 49 if get_password(room) ~= password then | 50 if get_password(room) ~= password then |
