From ef5dfa900fbdc742237d3e69879401566fa82fd3 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 28 Mar 2023 10:43:09 +0100 Subject: mod_tokenauth: Fire events on grant creation and revocation --- plugins/mod_tokenauth.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'plugins/mod_tokenauth.lua') diff --git a/plugins/mod_tokenauth.lua b/plugins/mod_tokenauth.lua index 94c740c0..5703f4a4 100644 --- a/plugins/mod_tokenauth.lua +++ b/plugins/mod_tokenauth.lua @@ -55,6 +55,13 @@ function create_grant(actor_jid, grant_jid, grant_ttl, grant_data) 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 @@ function revoke_token(token) 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) -- cgit v1.2.3