plugins/mod_register.lua

changeset 2085
64872e216e23
parent 1861
e9500c4994f3
child 2260
67b64995ae1e
equal deleted inserted replaced
2084:ded03b7b040e 2085:64872e216e23
115 else 115 else
116 local username = query:child_with_name("username"); 116 local username = query:child_with_name("username");
117 local password = query:child_with_name("password"); 117 local password = query:child_with_name("password");
118 if username and password then 118 if username and password then
119 -- Check that the user is not blacklisted or registering too often 119 -- Check that the user is not blacklisted or registering too often
120 if blacklisted_ips[session.ip] or (whitelist_only and not whitelisted_ips[session.ip]) then 120 if not session.ip then
121 module:log("debug", "User's IP not known; can't apply blacklist/whitelist");
122 elseif blacklisted_ips[session.ip] or (whitelist_only and not whitelisted_ips[session.ip]) then
121 session.send(st.error_reply(stanza, "cancel", "not-acceptable", "You are not allowed to register an account.")); 123 session.send(st.error_reply(stanza, "cancel", "not-acceptable", "You are not allowed to register an account."));
122 return; 124 return;
123 elseif min_seconds_between_registrations and not whitelisted_ips[session.ip] then 125 elseif min_seconds_between_registrations and not whitelisted_ips[session.ip] then
124 if not recent_ips[session.ip] then 126 if not recent_ips[session.ip] then
125 recent_ips[session.ip] = { time = os_time(), count = 1 }; 127 recent_ips[session.ip] = { time = os_time(), count = 1 };

mercurial