# HG changeset patch # User Marco Cirillo # Date 1302648026 0 # Node ID 72a5778579c52dc3affa5e7c08038b7f1c3dcfb8 # Parent bd0a8c032163c7cb5cc013d1526b4852283735b2 mod_register_json: Let's call it the first commit, fixed all code errors (aka it works). diff -r bd0a8c032163 -r 72a5778579c5 mod_register_json/mod_register_json.lua --- a/mod_register_json/mod_register_json.lua Tue Apr 12 20:50:43 2011 +0000 +++ b/mod_register_json/mod_register_json.lua Tue Apr 12 22:40:26 2011 +0000 @@ -61,6 +61,12 @@ module:log("debug", "JSON data submitted for user registration by %s failed to Decode.", user); return http_response(400, "JSON Decoding failed."); else + -- Decode JSON data and check that all bits are there else throw an error + req_body = json_decode(body); + if req_body["username"] == nil or req_body["password"] == nil or req_body["host"] == nil or req_body["ip"] == nil then + module:log("debug", "%s supplied an insufficent number of elements or wrong elements for the JSON registration", user); + return http_response(400, "Invalid syntax."); + end -- Check if user is an admin of said host if not usermanager.is_admin(user, req_body["host"]) then module:log("warn", "%s tried to submit registration data for %s but he's not an admin", user, req_body["host"]);