--- a/mod_http_oauth2/mod_http_oauth2.lua Mon Aug 30 20:19:15 2021 +0200
+++ b/mod_http_oauth2/mod_http_oauth2.lua Thu Sep 02 23:03:41 2021 +0200
@@ -23,8 +23,12 @@
return "prosody:scope:default";
end
+local function code_expires_in(code)
+ return os.difftime(os.time(), code.issued);
+end
+
local function code_expired(code)
- return os.difftime(os.time(), code.issued) > 120;
+ return code_expires_in(code) > 120;
end
local codes = cache.new(10000, function (_, code)
@@ -37,7 +41,7 @@
codes:set(k, nil);
k, code = codes:tail();
end
- return 900;
+ return code and code_expires_in(code) + 1 or 900;
end)
local function oauth_error(err_name, err_desc)