Changeset

439:c01679811fe8

mod_register_redirect: renamed mod_register_url, and added options to allow more customization.
author Marco Cirillo <maranda@lightwitch.org>
date Thu, 22 Sep 2011 15:00:39 +0000
parents 438:7f0cdde1e42a
children 440:9a71493368de
files mod_register_url/mod_register_url.lua
diffstat 1 files changed, 0 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/mod_register_url/mod_register_url.lua	Thu Sep 22 12:47:33 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +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 stanza, origin = event.stanza, event.origin;
-	local ip_wl = module:get_option("registration_whitelist") or { "127.0.0.1" };
-	local url = module:get_option("registration_url");
-	local no_wl = module:get_option_boolean("no_registration_whitelist", false);
-	local test_ip = false;
-
-	if not no_wl then
-		for i,ip in ipairs(ip_wl) do
-			if origin.ip == ip then test_ip = true; end
-			break;
-		end
-	end
-	
-	if stanza.attr.type == "get" then
-		local reply = st.reply(event.stanza);
-		reply:query("jabber:iq:register")
-			:tag("instructions"):text("Please visit "..url.." to register an account on this server."):up()
-			:tag("x", {xmlns = "jabber:x:oob"})
-				:tag("url"):text(url);
-		origin.send(reply);
-		return true;
-	else
-		origin.send(st.error_reply(stanza, "cancel", "not-authorized"))
-		return true
-	end
-end
-
-module:hook("stanza/iq/jabber:iq:register:query", reg_redirect, 10);