aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_tokenauth.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-10-21 12:33:55 +0200
committerKim Alvefur <zash@zash.se>2023-10-21 12:33:55 +0200
commit5425a43ba6443e2bfd31a09737aae152f5009580 (patch)
tree90e69f054f81045d31089c60655dc1bad708efaf /plugins/mod_tokenauth.lua
parentd9043249debc899bd066b932f928b7cd4062124e (diff)
downloadprosody-5425a43ba6443e2bfd31a09737aae152f5009580.tar.gz
prosody-5425a43ba6443e2bfd31a09737aae152f5009580.zip
mod_tokenauth: Save grant after removing expired tokens
Ensures the periodic cleanup really does remove expired tokens.
Diffstat (limited to 'plugins/mod_tokenauth.lua')
-rw-r--r--plugins/mod_tokenauth.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/plugins/mod_tokenauth.lua b/plugins/mod_tokenauth.lua
index d4a30a96..6034071a 100644
--- a/plugins/mod_tokenauth.lua
+++ b/plugins/mod_tokenauth.lua
@@ -167,9 +167,14 @@ local function _get_validated_grant_info(username, grant)
return nil, "invalid";
end
for secret_hash, token_info in pairs(grant.tokens) do
+ local found_expired = false
if token_info.expires and token_info.expires < now then
module:log("debug", "Token has expired, cleaning it up");
grant.tokens[secret_hash] = nil;
+ found_expired = true;
+ end
+ if found_expired then
+ token_store:set_key(username, grant.id, nil);
end
end