fix(mgmt_api): kickout non-existing clientid should return code `404`
This commit is contained in:
parent
c05ecdbcb8
commit
1dc0a2e8b5
|
@ -256,11 +256,16 @@ lookup_client(Node, {username, Username}, {M,F}) when Node =:= node() ->
|
|||
lookup_client(Node, {username, Username}, FormatFun) ->
|
||||
rpc_call(Node, lookup_client, [Node, {username, Username}, FormatFun]).
|
||||
|
||||
kickout_client(ClientId) ->
|
||||
Results = [kickout_client(Node, ClientId) || Node <- mria_mnesia:running_nodes()],
|
||||
case lists:any(fun(Item) -> Item =:= ok end, Results) of
|
||||
true -> ok;
|
||||
false -> lists:last(Results)
|
||||
kickout_client({ClientID, FormatFun}) ->
|
||||
case lookup_client({clientid, ClientID}, FormatFun) of
|
||||
[] ->
|
||||
{error, not_found};
|
||||
_ ->
|
||||
Results = [kickout_client(Node, ClientID) || Node <- mria_mnesia:running_nodes()],
|
||||
case lists:any(fun(Item) -> Item =:= ok end, Results) of
|
||||
true -> ok;
|
||||
false -> lists:last(Results)
|
||||
end
|
||||
end.
|
||||
|
||||
kickout_client(Node, ClientId) when Node =:= node() ->
|
||||
|
|
|
@ -505,8 +505,12 @@ lookup(#{clientid := ClientID}) ->
|
|||
end.
|
||||
|
||||
kickout(#{clientid := ClientID}) ->
|
||||
emqx_mgmt:kickout_client(ClientID),
|
||||
{204}.
|
||||
case emqx_mgmt:kickout_client({ClientID, ?FORMAT_FUN}) of
|
||||
{error, not_found} ->
|
||||
{404, ?CLIENT_ID_NOT_FOUND};
|
||||
_ ->
|
||||
{204}
|
||||
end.
|
||||
|
||||
get_authz_cache(#{clientid := ClientID})->
|
||||
case emqx_mgmt:list_authz_cache(ClientID) of
|
||||
|
|
Loading…
Reference in New Issue