Mercurial > prosody-hg
comparison plugins/muc/password.lib.lua @ 8996:2df7dc99566a
MUC/password: Rename variable for clarity [luacheck]
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 08 Jul 2018 03:43:47 +0200 |
| parents | e16b3fd0bd80 |
| children | 8c4dd4375823 |
comparison
equal
deleted
inserted
replaced
| 8995:2e6f7ab97794 | 8996:2df7dc99566a |
|---|---|
| 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 local password = stanza:get_child("x", "http://jabber.org/protocol/muc"); | 45 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc"); |
| 46 password = password and password:get_child_text("password", "http://jabber.org/protocol/muc"); | 46 if not muc_x then return end |
| 47 local password = muc_x:get_child_text("password", "http://jabber.org/protocol/muc"); | |
| 47 if not password or password == "" then password = nil; end | 48 if not password or password == "" then password = nil; end |
| 48 if get_password(room) ~= password then | 49 if get_password(room) ~= password then |
| 49 local from, to = stanza.attr.from, stanza.attr.to; | 50 local from, to = stanza.attr.from, stanza.attr.to; |
| 50 module:log("debug", "%s couldn't join due to invalid password: %s", from, to); | 51 module:log("debug", "%s couldn't join due to invalid password: %s", from, to); |
| 51 local reply = st.error_reply(stanza, "auth", "not-authorized"):up(); | 52 local reply = st.error_reply(stanza, "auth", "not-authorized"):up(); |
