Mercurial > prosody-modules
comparison mod_register_url/mod_register_url.lua @ 368:1f55e844efeb
mod_register_url: added option to specify no whitelististing is employed.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Sun, 17 Apr 2011 14:52:20 +0000 |
parents | 7dff5fa275f4 |
children | ee28af887507 |
comparison
equal
deleted
inserted
replaced
367:a6dee73a11e7 | 368:1f55e844efeb |
---|---|
5 local st = require "util.stanza"; | 5 local st = require "util.stanza"; |
6 | 6 |
7 function reg_redirect(event) | 7 function reg_redirect(event) |
8 local ip_wl = module:get_option("registration_whitelist") or { "127.0.0.1" }; | 8 local ip_wl = module:get_option("registration_whitelist") or { "127.0.0.1" }; |
9 local url = module:get_option("registration_url"); | 9 local url = module:get_option("registration_url"); |
10 local test_ip; | 10 local no_wl = module:get_option("no_registration_whitelist") or false; |
11 if type(no_wl) ~= boolean then no_wl = false end | |
12 local test_ip = false; | |
11 | 13 |
12 for i,ip in ipairs(ip_wl) do | 14 if not no_wl then |
13 if event.origin.ip == ip then test_ip = true; end | 15 for i,ip in ipairs(ip_wl) do |
14 break; | 16 if event.origin.ip == ip then test_ip = true; end |
17 break; | |
18 end | |
15 end | 19 end |
16 | 20 |
17 if not test_ip and url ~= nil then | 21 if not test_ip and url ~= nil or no_wl and url ~= nil then |
18 local reply = st.reply(event.stanza); | 22 local reply = st.reply(event.stanza); |
19 reply:tag("query", {xmlns = "jabber:iq:register"}) | 23 reply:tag("query", {xmlns = "jabber:iq:register"}) |
20 :tag("instructions"):text("Please visit "..url.." to register an account on this server."):up() | 24 :tag("instructions"):text("Please visit "..url.." to register an account on this server."):up() |
21 :tag("x", {xmlns = "jabber:x:oob"}):up() | 25 :tag("x", {xmlns = "jabber:x:oob"}):up() |
22 :tag("url"):text(url):up(); | 26 :tag("url"):text(url):up(); |