Software /
code /
prosody-modules
Diff
mod_block_registrations/mod_block_registrations.lua @ 1331:dbaa67babeb4
mod_block_registrations: Switch to using the 'user-registering' event
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 06 Mar 2014 01:10:21 +0100 |
parent | 1053:cabbcc1997d9 |
child | 1697:27aa58ed3e2e |
line wrap: on
line diff
--- a/mod_block_registrations/mod_block_registrations.lua Wed Mar 05 17:44:27 2014 +0100 +++ b/mod_block_registrations/mod_block_registrations.lua Thu Mar 06 01:10:21 2014 +0100 @@ -20,15 +20,10 @@ end end -module:hook("stanza/iq/jabber:iq:register:query", function(event) - local session, stanza = event.origin, event.stanza; - - if stanza.attr.type == "set" then - local query = stanza.tags[1]; - local username = nodeprep(query:get_child_text("username")); - if username and is_blocked(username) then - session.send(st.error_reply(stanza, "modify", "policy-violation", "Username is blocked")); - return true; - end +module:hook("user-registering", function(event) + local username = event.username; + if is_blocked(username) then + event.allowed = false; + return true; end end, 10);