From dbca0ed63c4f977fe73a3d125da013a446a524bf Mon Sep 17 00:00:00 2001 From: Janusz Jakubiec Date: Mon, 25 Jul 2022 08:58:48 +0200 Subject: [PATCH] Fixing mod_auth_token --- src/mod_auth_token.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mod_auth_token.erl b/src/mod_auth_token.erl index 1f1d7382f5..21f2b840a2 100644 --- a/src/mod_auth_token.erl +++ b/src/mod_auth_token.erl @@ -31,6 +31,9 @@ -export([deserialize/1, serialize/1]). +%% Command-line interface +-export([revoke_token_command/1]). + %% Test only! -export([datetime_to_seconds/1, seconds_to_datetime/1]). @@ -130,7 +133,7 @@ validity_period_spec() -> commands() -> [#ejabberd_commands{ name = revoke_token, tags = [tokens], desc = "Revoke REFRESH token", - module = mod_auth_token_api, function = revoke_token_command, + module = ?MODULE, function = revoke_token_command, args = [{owner, binary}], result = {res, restuple} }]. %% @@ -412,6 +415,16 @@ key_name(access) -> token_secret; key_name(refresh) -> token_secret; key_name(provision) -> provision_pre_shared. +-spec revoke_token_command(Owner) -> ResTuple when + Owner :: jid:jid(), + ResCode :: ok | not_found | error, + ResTuple :: {ResCode, string()}. +revoke_token_command(Owner) -> + case mod_auth_token_api:revoke_token_command(Owner) of + {ok, _} = Result -> Result; + {error, Error} -> Error + end. + -spec clean_tokens(mongoose_acc:t(), User :: jid:user(), Server :: jid:server()) -> mongoose_acc:t(). clean_tokens(Acc, User, Server) ->