mod_register_web: Handle errors contacting upstream API
authorMatthew Wild <mwild1@gmail.com>
Sun, 15 Apr 2018 12:39:32 +0100
changeset 3003 d631fd9a3300
parent 3002 719b76ee0578
child 3004 02fc3b64cbb7
mod_register_web: Handle errors contacting upstream API
mod_register_web/mod_register_web.lua
--- a/mod_register_web/mod_register_web.lua	Sat Apr 07 01:41:01 2018 +0200
+++ b/mod_register_web/mod_register_web.lua	Sun Apr 15 12:39:32 2018 +0100
@@ -58,7 +58,10 @@
 			};
 		}, function (verify_result, code)
 			local result = json(verify_result);
-			if result.success == true then
+			if not result then
+				module:log("warn", "Unable to decode response from recaptcha: [%d] %s", code, verify_result);
+				callback(false, "Captcha API error");
+			elseif result.success == true then
 				callback(true);
 			else
 				callback(false, t_concat(result["error-codes"]));