Software /
code /
prosody-modules
Comparison
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 |
comparison
equal
deleted
inserted
replaced
1330:bb6f3312ab46 | 1331:dbaa67babeb4 |
---|---|
18 if require_pattern and not username:match(require_pattern) then | 18 if require_pattern and not username:match(require_pattern) then |
19 return true; | 19 return true; |
20 end | 20 end |
21 end | 21 end |
22 | 22 |
23 module:hook("stanza/iq/jabber:iq:register:query", function(event) | 23 module:hook("user-registering", function(event) |
24 local session, stanza = event.origin, event.stanza; | 24 local username = event.username; |
25 | 25 if is_blocked(username) then |
26 if stanza.attr.type == "set" then | 26 event.allowed = false; |
27 local query = stanza.tags[1]; | 27 return true; |
28 local username = nodeprep(query:get_child_text("username")); | |
29 if username and is_blocked(username) then | |
30 session.send(st.error_reply(stanza, "modify", "policy-violation", "Username is blocked")); | |
31 return true; | |
32 end | |
33 end | 28 end |
34 end, 10); | 29 end, 10); |