comparison mod_register_url/mod_register_url.lua @ 113:7dff5fa275f4

Renamed mod_regredirect to mod_register_url, thanks MattJ for the suggestion.
author Marco Cirillo <maranda@lightwitch.org>
date Wed, 30 Dec 2009 15:49:49 +0000
parents mod_regredirect/mod_regredirect.lua@d1168a454107
children 1f55e844efeb
comparison
equal deleted inserted replaced
112:d1168a454107 113:7dff5fa275f4
1 -- Registration Redirect module for Prosody
2 --
3 -- Redirects IP addresses not in the whitelist to a web page to complete the registration.
4
5 local st = require "util.stanza";
6
7 function reg_redirect(event)
8 local ip_wl = module:get_option("registration_whitelist") or { "127.0.0.1" };
9 local url = module:get_option("registration_url");
10 local test_ip;
11
12 for i,ip in ipairs(ip_wl) do
13 if event.origin.ip == ip then test_ip = true; end
14 break;
15 end
16
17 if not test_ip and url ~= nil then
18 local reply = st.reply(event.stanza);
19 reply:tag("query", {xmlns = "jabber:iq:register"})
20 :tag("instructions"):text("Please visit "..url.." to register an account on this server."):up()
21 :tag("x", {xmlns = "jabber:x:oob"}):up()
22 :tag("url"):text(url):up();
23 event.origin.send(reply);
24 return true;
25 end
26 end
27
28 module:hook("stanza/iq/jabber:iq:register:query", reg_redirect, 10);