Software /
code /
prosody
Diff
plugins/mod_tokenauth.lua @ 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 |
parent | 13000:c7253174503e |
child | 13006:d943733c6d01 |
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)