chore(match): reduce the risk of crash

This commit is contained in:
zhouzb 2021-08-19 09:23:38 +08:00
parent e5892d16e5
commit 178d1006e1
1 changed files with 4 additions and 4 deletions

View File

@ -1302,13 +1302,13 @@ authenticate(?AUTH_PACKET(_, #{'Authentication-Method' := AuthMethod} = Properti
do_authenticate(#{auth_method := AuthMethod} = Credential, #channel{clientinfo = ClientInfo} = Channel) -> do_authenticate(#{auth_method := AuthMethod} = Credential, #channel{clientinfo = ClientInfo} = Channel) ->
Properties = #{'Authentication-Method' => AuthMethod}, Properties = #{'Authentication-Method' => AuthMethod},
case emqx_access_control:authenticate(Credential) of case emqx_access_control:authenticate(Credential) of
{ok, #{superuser := Superuser}} -> {ok, Result} ->
{ok, Properties, {ok, Properties,
Channel#channel{clientinfo = ClientInfo#{is_superuser => Superuser}, Channel#channel{clientinfo = ClientInfo#{is_superuser => maps:get(superuser, Result, false)},
auth_cache = #{}}}; auth_cache = #{}}};
{ok, #{superuser := Superuser}, AuthData} -> {ok, Result, AuthData} ->
{ok, Properties#{'Authentication-Data' => AuthData}, {ok, Properties#{'Authentication-Data' => AuthData},
Channel#channel{clientinfo = ClientInfo#{is_superuser => Superuser}, Channel#channel{clientinfo = ClientInfo#{is_superuser => maps:get(superuser, Result, false)},
auth_cache = #{}}}; auth_cache = #{}}};
{continue, AuthCache} -> {continue, AuthCache} ->
{continue, Properties, Channel#channel{auth_cache = AuthCache}}; {continue, Properties, Channel#channel{auth_cache = AuthCache}};