diff mod_register_web/mod_register_web.lua @ 1234:da39ba4047a7

mod_register_web: Pass request to captcha handler
author Kim Alvefur <zash@zash.se>
date Sat, 30 Nov 2013 22:10:41 +0100
parents f7b1992e4ff6
children 9277e0a3922f
line wrap: on
line diff
--- a/mod_register_web/mod_register_web.lua	Sat Nov 30 22:10:07 2013 +0100
+++ b/mod_register_web/mod_register_web.lua	Sat Nov 30 22:10:41 2013 +0100
@@ -36,7 +36,7 @@
 			end
 		}));
 	end
-	function verify_captcha(form, callback)
+	function verify_captcha(request, form, callback)
 		http.request("https://www.google.com/recaptcha/api/verify", {
 			body = http.formencode {
 				privatekey = captcha_options.recaptcha_private_key;
@@ -81,7 +81,7 @@
 			op = op, x = x, y = y, challenge = challenge;
 		};
 	end
-	function verify_captcha(form, callback)
+	function verify_captcha(request, form, callback)
 		if hmac_sha1(secret, form.captcha_reply, true) == form.captcha_challenge then
 			callback(true);
 		else
@@ -135,7 +135,7 @@
 function handle_form(event)
 	local request, response = event.request, event.response;
 	local form = http.formdecode(request.body);
-	verify_captcha(form, function (ok, err)
+	verify_captcha(request, form, function (ok, err)
 		if ok then
 			local register_ok, register_err = register_user(form);
 			response:send(generate_register_response(event, form, register_ok, register_err));