Software / code / prosody
Changeset
13003:34ed17ef1c1a
mod_tokenauth: Fire events on grant creation and revocation
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 28 Mar 2023 10:43:09 +0100 |
| parents | 13002:d8e2b995f975 |
| children | 13004:47efa93ea859 |
| files | plugins/mod_tokenauth.lua |
| diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_tokenauth.lua Tue Mar 28 11:27:05 2023 +0200 +++ b/plugins/mod_tokenauth.lua Tue Mar 28 10:43:09 2023 +0100 @@ -55,6 +55,13 @@ return nil, err; end + module:fire_event("token-grant-created", { + id = grant_id; + grant = grant; + username = grant_username; + host = grant_host; + }); + return grant; end @@ -226,7 +233,12 @@ if token_host ~= module.host then return nil, "invalid-host"; end - return token_store:set_key(token_user, token_id, nil); + local ok, err = token_store:set_key(token_user, token_id, nil); + if not ok then + return nil, err; + end + module:fire_event("token-grant-revoked", { id = token_id, username = token_user, host = token_host }); + return true; end function sasl_handler(auth_provider, purpose, extra)