./ct_report/coverage/mongoose_graphql_token_user_mutation.COVER.html

1 -module(mongoose_graphql_token_user_mutation).
2 -behaviour(mongoose_graphql).
3
4 -export([execute/4]).
5
6 -ignore_xref([execute/4]).
7
8 -include("../mongoose_graphql_types.hrl").
9
10 -import(mongoose_graphql_helper, [make_error/2]).
11
12 -type token_info() :: map().
13 -type args() :: mongoose_graphql:args().
14 -type ctx() :: mongoose_graphql:context().
15
16 execute(Ctx, token, <<"requestToken">>, Args) ->
17 2 request_token(Ctx, Args);
18 execute(Ctx, token, <<"revokeToken">>, Args) ->
19 2 revoke_token(Ctx, Args).
20
21 -spec request_token(ctx(), args()) -> {ok, token_info()} | {error, resolver_error()}.
22 request_token(#{user := JID}, #{}) ->
23 2 case mod_auth_token_api:create_token(JID) of
24 2 {ok, _} = Result -> Result;
25
:-(
Error -> make_error(Error, #{user => JID})
26 end.
27
28 -spec revoke_token(ctx(), args()) -> {ok, string()} | {error, resolver_error()}.
29 revoke_token(#{user := JID}, #{}) ->
30 2 case mod_auth_token_api:revoke_token_command(JID) of
31 1 {ok, _} = Result -> Result;
32 1 Error -> make_error(Error, #{user => JID})
33 end.
Line Hits Source