diff options
author | Kim Alvefur <zash@zash.se> | 2023-11-05 16:10:40 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2023-11-05 16:10:40 +0100 |
commit | deaa31ddc00bc67007ad21f064df52f2c678e755 (patch) | |
tree | e6e680a2475a03089d3018dfdd4f30927fe0c805 /plugins | |
parent | ae884642d512b3b69a2240f950d703693c7e4099 (diff) | |
download | prosody-deaa31ddc00bc67007ad21f064df52f2c678e755.tar.gz prosody-deaa31ddc00bc67007ad21f064df52f2c678e755.zip |
mod_tokenauth: Fix saving grants after clearing expired tokens
Previously the whole grant was deleted if it found one expired toke,
which was not indented.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_tokenauth.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/mod_tokenauth.lua b/plugins/mod_tokenauth.lua index 35fb08c5..658aa39d 100644 --- a/plugins/mod_tokenauth.lua +++ b/plugins/mod_tokenauth.lua @@ -166,22 +166,22 @@ local function _get_validated_grant_info(username, grant) token_store:set_key(username, grant.id, nil); return nil, "invalid"; end + + local found_expired = false 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 if not grant.expires and next(grant.tokens) == nil and grant.accessed + empty_grant_lifetime < now then module:log("debug", "Token grant has no tokens, discarding"); token_store:set_key(username, grant.id, nil); return nil, "expired"; + elseif found_expired then + token_store:set_key(username, grant.id, grant); end return grant; |