chore: no duplicated reads and some comment/message rewording

Co-authored-by: Dmitrii <99872536+ieQu1@users.noreply.github.com>
This commit is contained in:
Zaiming (Stone) Shi 2022-04-05 13:23:44 +02:00
parent 6cc55f5c34
commit 155befe418
2 changed files with 7 additions and 7 deletions

View File

@ -161,11 +161,11 @@ lookup_user(Username) when is_binary(Username) ->
case mnesia:dirty_read(mqtt_admin, Username) of case mnesia:dirty_read(mqtt_admin, Username) of
[] when IsDefaultUser -> [] when IsDefaultUser ->
_ = ensure_default_user_in_db(Username), _ = ensure_default_user_in_db(Username),
ok; %% try to read again
_ -> mnesia:dirty_read(mqtt_admin, Username);
ok Res ->
end, Res
mnesia:dirty_read(mqtt_admin, Username). end.
-spec(all_users() -> [#mqtt_admin{}]). -spec(all_users() -> [#mqtt_admin{}]).
all_users() -> ets:tab2list(mqtt_admin). all_users() -> ets:tab2list(mqtt_admin).
@ -296,7 +296,7 @@ maybe_warn_default_pwd() ->
true -> true ->
?LOG(warning, ?LOG(warning,
"[Dashboard] Using default password for dashboard 'admin' user. " "[Dashboard] Using default password for dashboard 'admin' user. "
"Please use the './bin/emqx_ctl admins' CLI to change it. " "Please use './bin/emqx_ctl admins' command to change it. "
"NOTE: the default password in config file is only " "NOTE: the default password in config file is only "
"used to initialise the database record, changing the config " "used to initialise the database record, changing the config "
"file after database is initialised has no effect." "file after database is initialised has no effect."

View File

@ -99,7 +99,7 @@ t_admins_persist_default_password(_) ->
ct:sleep(100), ct:sleep(100),
%% It get's restarted by the app automatically %% It gets restarted by the app automatically
[#mqtt_admin{password=PasswordAfterRestart}] = emqx_dashboard_admin:lookup_user(<<"admin">>), [#mqtt_admin{password=PasswordAfterRestart}] = emqx_dashboard_admin:lookup_user(<<"admin">>),
?assertEqual(Password, PasswordAfterRestart), ?assertEqual(Password, PasswordAfterRestart),
emqx_dashboard_admin:change_password(<<"admin">>, <<"public">>). emqx_dashboard_admin:change_password(<<"admin">>, <<"public">>).