comparison mod_regredirect/mod_regredirect.lua @ 112:d1168a454107

mod_regredirect: initial commit.
author Marco Cirillo <maranda@lightwitch.org>
date Wed, 30 Dec 2009 00:24:24 +0000
parents
children
comparison
equal deleted inserted replaced
111:3de60860adca 112:d1168a454107
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);