Add warning log for unauthored subscribe

Prior to this change, there is no log for unauthored log, it is
difficult to find the problem when subscription error occured.
This commit is contained in:
Gilbert Wong 2018-09-29 19:17:58 +08:00 committed by Feng Lee
parent 0adee194aa
commit 30d986c318
1 changed files with 5 additions and 1 deletions

View File

@ -747,7 +747,11 @@ check_sub_acl(TopicFilters, PState) ->
fun({Topic, SubOpts}, {Ok, Acc}) ->
case emqx_access_control:check_acl(Credentials, subscribe, Topic) of
allow -> {Ok, [{Topic, SubOpts}|Acc]};
deny -> {error, [{Topic, SubOpts#{rc := ?RC_NOT_AUTHORIZED}}|Acc]}
deny ->
emqx_logger:warning([{client, PState#pstate.client_id}],
"ACL(~s) Cannot SUBSCRIBE ~p for ACL Deny",
[PState#pstate.client_id, Topic]),
{error, [{Topic, SubOpts#{rc := ?RC_NOT_AUTHORIZED}}|Acc]}
end
end, {ok, []}, TopicFilters).