# HG changeset patch # User Marco Cirillo # Date 1367271561 -7200 # Node ID 929dcf3c4bcbdd2055addd80c2a87b0eb80f189e # Parent 17ba2c59d6618614b4767528df602dcc7cdd5b70 mod_register_json: small code cleanup & optimization. diff -r 17ba2c59d661 -r 929dcf3c4bcb mod_register_json/register_json/mod_register_json.lua --- a/mod_register_json/register_json/mod_register_json.lua Mon Apr 29 23:32:16 2013 +0200 +++ b/mod_register_json/register_json/mod_register_json.lua Mon Apr 29 23:39:21 2013 +0200 @@ -87,9 +87,7 @@ end local function handle_req(event) - local response = event.response local request = event.request - local body = request.body if secure and not request.secure then return nil end if request.method ~= "POST" then @@ -98,7 +96,7 @@ local req_body -- We check that what we have is valid JSON wise else we throw an error... - if not pcall(function() req_body = json_decode(b64_decode(body)) end) then + if not pcall(function() req_body = json_decode(b64_decode(request.body)) end) then module:log("debug", "Data submitted for user registration by %s failed to Decode.", user) return http_response(event, 400, "Decoding failed.") else @@ -189,8 +187,6 @@ end local function r_template(event, type) - local response = event.response - local data = open_file(files_base..type.."_t.html") if data then data = data:gsub("%%REG%-URL", base_path.."verify/") @@ -199,7 +195,6 @@ end local function handle_verify(event, path) - local response = event.response local request = event.request local body = request.body if secure and not request.secure then return nil end @@ -222,8 +217,8 @@ end elseif request.method == "POST" then if path == "" then - if not request.body then return http_response(event, 400, "Bad Request.") end - local uuid = urldecode(request.body):match("^uuid=(.*)$") + if not body then return http_response(event, 400, "Bad Request.") end + local uuid = urldecode(body):match("^uuid=(.*)$") if not pending[uuid] then return r_template(event, "fail")