Feng Lee 9 лет назад
Родитель
Сommit
76851e58fb
2 измененных файлов с 4 добавлено и 1 удалено
  1. 1 1
      rel/files/emqttd.test.config
  2. 3 0
      src/emqttd_auth_username.erl

+ 1 - 1
rel/files/emqttd.test.config

@@ -46,7 +46,7 @@
         %% Authetication. Anonymous Default
         {auth, [
             %% Authentication with username, password
-            %{username, []},
+            {username, [{test, "password"}, {"test1", "password1"}]},
             
             %% Authentication with clientid
             %{clientid, [{password, no}, {file, "etc/clients.config"}]},

+ 3 - 0
src/emqttd_auth_username.erl

@@ -77,6 +77,9 @@ add_user(Username, Password) ->
     User = #?AUTH_USERNAME_TAB{username = Username, password = hash(Password)},
     ret(mnesia:transaction(fun mnesia:write/1, [User])).
 
+add_default_user(Username, Password) when is_atom(Username) ->
+    add_default_user(atom_to_list(Username), Password);
+
 add_default_user(Username, Password) ->
     add_user(iolist_to_binary(Username), iolist_to_binary(Password)).