Преглед изворни кода

refactor(authn): use hocon enum type for user_id_type

Zaiming (Stone) Shi пре 3 година
родитељ
комит
60ca1cb2a5

+ 1 - 4
apps/emqx_authn/src/simple_authn/emqx_authn_mnesia.erl

@@ -53,7 +53,6 @@
     group_match_spec/1
 ]).
 
--type user_id_type() :: clientid | username.
 -type user_group() :: binary().
 -type user_id() :: binary().
 
@@ -64,8 +63,6 @@
     is_superuser :: boolean()
 }).
 
--reflect_type([user_id_type/0]).
-
 -export([mnesia/1]).
 
 -boot_mnesia({mnesia, [boot]}).
@@ -115,7 +112,7 @@ desc(?CONF_NS) ->
 desc(_) ->
     undefined.
 
-user_id_type(type) -> typerefl:alias("string", user_id_type());
+user_id_type(type) -> hoconsc:enum([clientid, username]);
 user_id_type(desc) -> ?DESC(?FUNCTION_NAME);
 user_id_type(default) -> <<"username">>;
 user_id_type(required) -> true;

+ 0 - 3
apps/emqx_dashboard/src/emqx_dashboard_swagger.erl

@@ -580,9 +580,6 @@ hocon_schema_to_spec(?UNION(Types), LocalModule) ->
 hocon_schema_to_spec(Atom, _LocalModule) when is_atom(Atom) ->
     {#{type => string, enum => [Atom]}, []}.
 
-%% todo: Find a way to fetch enum value from user_id_type().
-typename_to_spec("user_id_type()", _Mod) ->
-    #{type => string, enum => [clientid, username]};
 typename_to_spec("term()", _Mod) ->
     #{type => string, example => <<"any">>};
 typename_to_spec("boolean()", _Mod) ->