Commit fec534a1 authored by Taegyun Kim's avatar Taegyun Kim

add auth

parent 2fdbf48b
......@@ -10,8 +10,14 @@ load() ->
emqx:hook('client.authenticate', {?MODULE, on_client_authenticate, []}).
on_client_authenticate(#{username := Username, password := Password}, AuthResult) ->
io:format("username: ~w, password: ~w~n", [Username, Password]),
{ok, AuthResult}.
if
(Username == undefined) and (Password == undefined) ->
{stop, AuthResult#{username => anonymous, auth_result => success, anonymous => false}};
(Username == '') and (Password == '') ->
{stop, AuthResult#{username => anonymous, auth_result => success, anonymous => false}};
true ->
{ok, AuthResult}
end.
unload() ->
emqx:unhook('client.authenticate', {?MODULE, on_client_authenticate}).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment