# HG changeset patch # User Marco Cirillo # Date 1262188189 0 # Node ID 7dff5fa275f4c72bc3a00d8a31be798ea1abd201 # Parent d1168a4541072e30a99b7071183f7f855973187e Renamed mod_regredirect to mod_register_url, thanks MattJ for the suggestion. diff -r d1168a454107 -r 7dff5fa275f4 mod_register_url/mod_register_url.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_register_url/mod_register_url.lua Wed Dec 30 15:49:49 2009 +0000 @@ -0,0 +1,28 @@ +-- Registration Redirect module for Prosody +-- +-- Redirects IP addresses not in the whitelist to a web page to complete the registration. + +local st = require "util.stanza"; + +function reg_redirect(event) + local ip_wl = module:get_option("registration_whitelist") or { "127.0.0.1" }; + local url = module:get_option("registration_url"); + local test_ip; + + for i,ip in ipairs(ip_wl) do + if event.origin.ip == ip then test_ip = true; end + break; + end + + if not test_ip and url ~= nil then + local reply = st.reply(event.stanza); + reply:tag("query", {xmlns = "jabber:iq:register"}) + :tag("instructions"):text("Please visit "..url.." to register an account on this server."):up() + :tag("x", {xmlns = "jabber:x:oob"}):up() + :tag("url"):text(url):up(); + event.origin.send(reply); + return true; + end +end + +module:hook("stanza/iq/jabber:iq:register:query", reg_redirect, 10); diff -r d1168a454107 -r 7dff5fa275f4 mod_regredirect/mod_regredirect.lua --- a/mod_regredirect/mod_regredirect.lua Wed Dec 30 00:24:24 2009 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ --- Registration Redirect module for Prosody --- --- Redirects IP addresses not in the whitelist to a web page to complete the registration. - -local st = require "util.stanza"; - -function reg_redirect(event) - local ip_wl = module:get_option("registration_whitelist") or { "127.0.0.1" }; - local url = module:get_option("registration_url"); - local test_ip; - - for i,ip in ipairs(ip_wl) do - if event.origin.ip == ip then test_ip = true; end - break; - end - - if not test_ip and url ~= nil then - local reply = st.reply(event.stanza); - reply:tag("query", {xmlns = "jabber:iq:register"}) - :tag("instructions"):text("Please visit "..url.." to register an account on this server."):up() - :tag("x", {xmlns = "jabber:x:oob"}):up() - :tag("url"):text(url):up(); - event.origin.send(reply); - return true; - end -end - -module:hook("stanza/iq/jabber:iq:register:query", reg_redirect, 10);