This commit is contained in:
Feng Lee 2015-04-16 11:43:59 +08:00
parent 6fedab1e12
commit 50f2162968
1 changed files with 8 additions and 1 deletions

View File

@ -77,7 +77,14 @@ authorized(Req) ->
undefined ->
false;
"Basic " ++ BasicAuth ->
emqttd_auth:check(user_passwd(BasicAuth))
{Username, Password} = user_passwd(BasicAuth),
case emqttd_auth:login(#mqtt_client{username = Username}, Password) of
ok ->
true;
{error, Reason} ->
lager:error("HTTP Auth failure: username=~s, reason=~p", [Username, Reason]),
false
end
end.
user_passwd(BasicAuth) ->