Software /
code /
prosody-modules
Diff
mod_http_oauth2/mod_http_oauth2.lua @ 4258:cc712899becd
mod_http_oauth2: Unpack event object to improve readability
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 21 Nov 2020 16:36:44 +0100 |
parent | 4257:145e8e8a247a |
child | 4259:721b528c01e1 |
line wrap: on
line diff
--- 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));