# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1230593784 0
# Node ID 09e0e9c722a301373f2b78256657beea93bcde15
# Parent  30ccc5e3d8c8f899414ecfff0b6fe2b9904b1347
Add allow_registration option to disable account registration

diff -r 30ccc5e3d8c8 -r 09e0e9c722a3 plugins/mod_register.lua
--- a/plugins/mod_register.lua	Mon Dec 29 22:31:10 2008 +0000
+++ b/plugins/mod_register.lua	Mon Dec 29 23:36:24 2008 +0000
@@ -94,7 +94,9 @@
 end);
 
 module:add_iq_handler("c2s_unauthed", "jabber:iq:register", function (session, stanza)
-	if stanza.tags[1].name == "query" then
+	if config.get(module.host, "core", "allow_registration") == false then
+		session.send(st.error_reply(stanza, "cancel", "service-unavailable"));
+	elseif stanza.tags[1].name == "query" then
 		local query = stanza.tags[1];
 		if stanza.attr.type == "get" then
 			local reply = st.reply(stanza);
@@ -132,3 +134,4 @@
 		session.send(st.error_reply(stanza, "cancel", "service-unavailable"));
 	end;
 end);
+