Mercurial > prosody-modules
comparison mod_block_registrations/mod_block_registrations.lua @ 6321:2f01497b04c9
mod_block_registrations: Fix indentation
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 06 Sep 2025 19:25:15 +0200 |
| parents | 368bf9b06484 |
| children | f110bce35630 |
comparison
equal
deleted
inserted
replaced
| 6320:57cf3fc844f6 | 6321:2f01497b04c9 |
|---|---|
| 9 }); | 9 }); |
| 10 local block_patterns = module:get_option_set("block_registrations_matching", {}); | 10 local block_patterns = module:get_option_set("block_registrations_matching", {}); |
| 11 local require_pattern = module:get_option_string("block_registrations_require"); | 11 local require_pattern = module:get_option_string("block_registrations_require"); |
| 12 | 12 |
| 13 function is_blocked(username) | 13 function is_blocked(username) |
| 14 -- Check if the username is simply blocked | 14 -- Check if the username is simply blocked |
| 15 if block_users:contains(username) then return true; end | 15 if block_users:contains(username) then return true; end |
| 16 | 16 |
| 17 for pattern in block_patterns do | 17 for pattern in block_patterns do |
| 18 if username:find(pattern) then | 18 if username:find(pattern) then |
| 19 return true; | 19 return true; |
| 20 end | 20 end |
| 21 end | 21 end |
| 22 -- Not blocked, but check that username matches allowed pattern | 22 -- Not blocked, but check that username matches allowed pattern |
| 23 if require_pattern and not username:match(require_pattern) then | 23 if require_pattern and not username:match(require_pattern) then |
| 24 return true; | 24 return true; |
| 25 end | 25 end |
| 26 end | 26 end |
| 27 | 27 |
| 28 module:hook("user-registering", function(event) | 28 module:hook("user-registering", function(event) |
| 29 local username = event.username; | 29 local username = event.username; |
| 30 if is_blocked(username) then | 30 if is_blocked(username) then |
| 31 event.allowed = false; | 31 event.allowed = false; |
| 32 return true; | 32 return true; |
| 33 end | 33 end |
| 34 end, 10); | 34 end, 10); |
