fix(dashboard): fix nit codes

This commit is contained in:
firest 2022-08-11 17:42:22 +08:00
parent 463d255c0a
commit d55c9341eb
3 changed files with 22 additions and 5 deletions

View File

@ -203,8 +203,19 @@ its own from which a browser should permit loading resources."""
zh: "初始化用户文件" zh: "初始化用户文件"
} }
label { label {
en: "Initialize users file" en: """Is used to add an administrative user to Dashboard when emqx is first launched,
zh: "初始化用户文件" the format is:
```
username1:password1
username2:password2
```
"""
zh: """用于在首次启动 emqx 时,为 Dashboard 添加管理用户,其格式为:
```
username1:password1
username2:password2
```
"""
} }
} }
} }

View File

@ -19,6 +19,7 @@
-module(emqx_dashboard_admin). -module(emqx_dashboard_admin).
-include("emqx_dashboard.hrl"). -include("emqx_dashboard.hrl").
-include_lib("emqx/include/logger.hrl").
-include_lib("stdlib/include/ms_transform.hrl"). -include_lib("stdlib/include/ms_transform.hrl").
-boot_mnesia({mnesia, [boot]}). -boot_mnesia({mnesia, [boot]}).
@ -91,6 +92,7 @@ add_bootstrap_user() ->
File -> File ->
case mnesia:table_info(?ADMIN, size) of case mnesia:table_info(?ADMIN, size) of
0 -> 0 ->
?SLOG(debug, #{msg => "Add dashboard bootstrap users", file => File}),
add_bootstrap_user(File); add_bootstrap_user(File);
_ -> _ ->
ok ok

View File

@ -31,9 +31,13 @@ start(_StartType, _StartArgs) ->
case emqx_dashboard:start_listeners() of case emqx_dashboard:start_listeners() of
ok -> ok ->
emqx_dashboard_cli:load(), emqx_dashboard_cli:load(),
ok = emqx_dashboard_admin:add_bootstrap_user(), case emqx_dashboard_admin:add_bootstrap_user() of
{ok, _} = emqx_dashboard_admin:add_default_user(), ok ->
{ok, Sup}; {ok, _} = emqx_dashboard_admin:add_default_user(),
{ok, Sup};
Error ->
Error
end;
{error, Reason} -> {error, Reason} ->
{error, Reason} {error, Reason}
end. end.