Software / code / prosody-modules
Changeset
6308:e1c54de06905
mod_http_oauth2: Handle case of device state having expired
If for some reason the `code` was nil, it would have thrown an error
attempting to index it.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 13 Jun 2025 21:57:38 +0200 |
| parents | 6307:aae94f82c56e |
| children | 6309:342f88e8d522 6310:30adcea825c3 |
| files | mod_http_oauth2/mod_http_oauth2.lua |
| diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_oauth2/mod_http_oauth2.lua Fri Jun 13 21:30:56 2025 +0200 +++ b/mod_http_oauth2/mod_http_oauth2.lua Fri Jun 13 21:57:38 2025 +0200 @@ -796,9 +796,11 @@ if is_device then local device_code = b64url(hashes.hmac_sha256(verification_key, device_state.user_code)); local code = codes:get("device_code:" .. params.client_id .. "#" .. device_code); - code.error = err; - code.expires = os.time() + 60; - codes:set("device_code:" .. params.client_id .. "#" .. device_code, code); + if type(code) == "table" then + code.error = err; + code.expires = os.time() + 60; + codes:set("device_code:" .. params.client_id .. "#" .. device_code, code); + end end return render_error(err); end