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) ->
|
lookup_client(Node, {username, Username}, FormatFun) ->
|
||||||
rpc_call(Node, lookup_client, [Node, {username, Username}, FormatFun]).
|
rpc_call(Node, lookup_client, [Node, {username, Username}, FormatFun]).
|
||||||
|
|
||||||
kickout_client(ClientId) ->
|
kickout_client({ClientID, FormatFun}) ->
|
||||||
Results = [kickout_client(Node, ClientId) || Node <- mria_mnesia:running_nodes()],
|
case lookup_client({clientid, ClientID}, FormatFun) of
|
||||||
case lists:any(fun(Item) -> Item =:= ok end, Results) of
|
[] ->
|
||||||
true -> ok;
|
{error, not_found};
|
||||||
false -> lists:last(Results)
|
_ ->
|
||||||
|
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.
|
end.
|
||||||
|
|
||||||
kickout_client(Node, ClientId) when Node =:= node() ->
|
kickout_client(Node, ClientId) when Node =:= node() ->
|
||||||
|
|
|
@ -505,8 +505,12 @@ lookup(#{clientid := ClientID}) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
kickout(#{clientid := ClientID}) ->
|
kickout(#{clientid := ClientID}) ->
|
||||||
emqx_mgmt:kickout_client(ClientID),
|
case emqx_mgmt:kickout_client({ClientID, ?FORMAT_FUN}) of
|
||||||
{204}.
|
{error, not_found} ->
|
||||||
|
{404, ?CLIENT_ID_NOT_FOUND};
|
||||||
|
_ ->
|
||||||
|
{204}
|
||||||
|
end.
|
||||||
|
|
||||||
get_authz_cache(#{clientid := ClientID})->
|
get_authz_cache(#{clientid := ClientID})->
|
||||||
case emqx_mgmt:list_authz_cache(ClientID) of
|
case emqx_mgmt:list_authz_cache(ClientID) of
|
||||||
|
|
Loading…
Reference in New Issue