aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_register.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-05-28 00:21:12 +0100
committerMatthew Wild <mwild1@gmail.com>2011-05-28 00:21:12 +0100
commit87fabe0fe7c65949f55b0b310fc80fd811029335 (patch)
treea8fe1e6ff8e9aa2911becff9cee43e0e8f8351b8 /plugins/mod_register.lua
parent49d51d062d8d71a29b08a0db972ed80e10c77f6d (diff)
downloadprosody-87fabe0fe7c65949f55b0b310fc80fd811029335.tar.gz
prosody-87fabe0fe7c65949f55b0b310fc80fd811029335.zip
mod_register: Move allow_registration option into an upvalue for efficiency (now it is being checked on every new c2s stream)
Diffstat (limited to 'plugins/mod_register.lua')
-rw-r--r--plugins/mod_register.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua
index b4683b58..50d29da8 100644
--- a/plugins/mod_register.lua
+++ b/plugins/mod_register.lua
@@ -19,6 +19,7 @@ local nodeprep = require "util.encodings".stringprep.nodeprep;
local jid_bare = require "util.jid".bare;
local compat = module:get_option_boolean("registration_compat", true);
+local allow_registration = module:get_option_boolean("allow_registration", true);
module:add_feature("jabber:iq:register");
@@ -27,7 +28,7 @@ module:hook("stream-features", function(event)
local session, features = event.origin, event.features;
-- Advertise registration to unauthorized clients only.
- if module:get_option("allow_registration") == false or session.type ~= "c2s_unauthed" then
+ if not(allow_registration) or session.type ~= "c2s_unauthed" then
return
end
@@ -126,7 +127,7 @@ for _, ip in ipairs(blacklisted_ips) do blacklisted_ips[ip] = true; end
module:hook("stanza/iq/jabber:iq:register:query", function(event)
local session, stanza = event.origin, event.stanza;
- if module:get_option("allow_registration") == false or session.type ~= "c2s_unauthed" then
+ if not(allow_registration) or session.type ~= "c2s_unauthed" then
session.send(st.error_reply(stanza, "cancel", "service-unavailable"));
else
local query = stanza.tags[1];