Changeset

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
parents 1330:bb6f3312ab46
children 1332:08a0241f5d2c
files mod_block_registrations/mod_block_registrations.lua
diffstat 1 files changed, 5 insertions(+), 10 deletions(-) [+]
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);