chore: clear_table mqtt_admin when failed
This commit is contained in:
parent
47d88186d1
commit
d37ad38e7a
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_dashboard,
|
{application, emqx_dashboard,
|
||||||
[{description, "EMQ X Web Dashboard"},
|
[{description, "EMQ X Web Dashboard"},
|
||||||
{vsn, "4.3.19"}, % strict semver, bump manually!
|
{vsn, "4.3.18"}, % strict semver, bump manually!
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_dashboard_sup]},
|
{registered, [emqx_dashboard_sup]},
|
||||||
{applications, [kernel,stdlib,mnesia,minirest]},
|
{applications, [kernel,stdlib,mnesia,minirest]},
|
||||||
|
|
|
@ -212,9 +212,9 @@ add_bootstrap_users(File, 0) ->
|
||||||
ok -> ok;
|
ok -> ok;
|
||||||
Error ->
|
Error ->
|
||||||
%% if failed add bootstrap users, we should clear all bootstrap users
|
%% if failed add bootstrap users, we should clear all bootstrap users
|
||||||
{atomic, ok} = mnesia:transaction(fun clear_bootstrap_users/0, []),
|
{atomic, ok} = mnesia:clear_table(mqtt_admin),
|
||||||
Error
|
Error
|
||||||
end;
|
end;
|
||||||
{error, Reason} = Error ->
|
{error, Reason} = Error ->
|
||||||
?LOG(error,
|
?LOG(error,
|
||||||
"failed to open the dashboard bootstrap users file(~s) for ~p",
|
"failed to open the dashboard bootstrap users file(~s) for ~p",
|
||||||
|
@ -258,14 +258,6 @@ add_bootstrap_user(File, Dev, MP, Line) ->
|
||||||
throw(#{file => File, line => Line, reason => Error})
|
throw(#{file => File, line => Line, reason => Error})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
clear_bootstrap_users() ->
|
|
||||||
FoldFun =
|
|
||||||
fun(#mqtt_admin{tags = ?BOOTSTRAP_USER_TAG} = User, Acc) ->
|
|
||||||
mnesia:delete_object(User), Acc;
|
|
||||||
(_, Acc) -> Acc
|
|
||||||
end,
|
|
||||||
mnesia:foldl(FoldFun, ok, mqtt_admin).
|
|
||||||
|
|
||||||
bad_login_penalty() ->
|
bad_login_penalty() ->
|
||||||
timer:sleep(2000),
|
timer:sleep(2000),
|
||||||
ok.
|
ok.
|
||||||
|
|
Loading…
Reference in New Issue