comparison mod_register_web/mod_register_web.lua @ 2999:d631fd9a3300

mod_register_web: Handle errors contacting upstream API
author Matthew Wild <mwild1@gmail.com>
date Sun, 15 Apr 2018 12:39:32 +0100
parents 3a104a900af1
children 866167118d23
comparison
equal deleted inserted replaced
2998:719b76ee0578 2999:d631fd9a3300
56 remoteip = request.conn:ip(); 56 remoteip = request.conn:ip();
57 response = form["g-recaptcha-response"]; 57 response = form["g-recaptcha-response"];
58 }; 58 };
59 }, function (verify_result, code) 59 }, function (verify_result, code)
60 local result = json(verify_result); 60 local result = json(verify_result);
61 if result.success == true then 61 if not result then
62 module:log("warn", "Unable to decode response from recaptcha: [%d] %s", code, verify_result);
63 callback(false, "Captcha API error");
64 elseif result.success == true then
62 callback(true); 65 callback(true);
63 else 66 else
64 callback(false, t_concat(result["error-codes"])); 67 callback(false, t_concat(result["error-codes"]));
65 end 68 end
66 end); 69 end);