# HG changeset patch # User Kim Alvefur # Date 1630616818 -7200 # Node ID 1b81b7269858f927ea9ad60110acf121e6dc8247 # Parent d3434fd151b5c7b9f8e5271a981dd48ae2445522 mod_http_oauth2: Gracefully handle cache write failure Would previously have thrown an error and probably returned a traceback. This would only happen if a *lot* of authorization codes were requested in a short interval. diff -r d3434fd151b5 -r 1b81b7269858 mod_http_oauth2/mod_http_oauth2.lua --- a/mod_http_oauth2/mod_http_oauth2.lua Thu Sep 02 23:03:41 2021 +0200 +++ b/mod_http_oauth2/mod_http_oauth2.lua Thu Sep 02 23:06:58 2021 +0200 @@ -102,11 +102,14 @@ local granted_scopes = filter_scopes(granted_jid, params.scope); local code = uuid.generate(); - assert(codes:set(params.client_id .. "#" .. code, { + local ok = codes:set(params.client_id .. "#" .. code, { issued = os.time(); granted_jid = granted_jid; granted_scopes = granted_scopes; - })); + }); + if not ok then + return {status_code = 429}; + end local redirect = url.parse(params.redirect_uri); local query = http.formdecode(redirect.query or "");