atom_to_list(Username)

This commit is contained in:
Feng Lee 2016-05-03 18:31:58 +08:00
parent 816827e1ee
commit 76851e58fb
2 changed files with 4 additions and 1 deletions

View File

@ -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"}]},

View File

@ -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)).