# HG changeset patch # User Kim Alvefur # Date 1605973004 -3600 # Node ID cc712899becdfa7d96a1cafa12b7bf72e8aefb6a # Parent 145e8e8a247a3c2c55b81b29a20c288779626dfe mod_http_oauth2: Unpack event object to improve readability diff -r 145e8e8a247a -r cc712899becd mod_http_oauth2/mod_http_oauth2.lua --- a/mod_http_oauth2/mod_http_oauth2.lua Sat Nov 21 16:05:55 2020 +0100 +++ b/mod_http_oauth2/mod_http_oauth2.lua Sat Nov 21 16:36:44 2020 +0100 @@ -175,26 +175,27 @@ end local function handle_authorization_request(event) - if not event.request.headers.authorization then - event.response.headers.www_authenticate = string.format("Basic realm=%q", module.host.."/"..module.name); + local request, response = event.request, event.response; + if not request.headers.authorization then + response.headers.www_authenticate = string.format("Basic realm=%q", module.host.."/"..module.name); return 401; end - local user = check_credentials(event.request); + local user = check_credentials(request); if not user then return 401; end - if not event.request.url.query then - event.response.headers.content_type = "application/json"; + if not request.url.query then + response.headers.content_type = "application/json"; return oauth_error("invalid_request"); end - local params = http.formdecode(event.request.url.query); + local params = http.formdecode(request.url.query); if not params then return oauth_error("invalid_request"); end local response_type = params.response_type; local response_handler = response_type_handlers[response_type]; if not response_handler then - event.response.headers.content_type = "application/json"; + response.headers.content_type = "application/json"; return oauth_error("unsupported_response_type"); end return response_handler(params, jid.join(user, module.host));