Преглед на файлове

chore(match): reduce the risk of crash

zhouzb преди 4 години
родител
ревизия
178d1006e1
променени са 1 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 4 4
      apps/emqx/src/emqx_channel.erl

+ 4 - 4
apps/emqx/src/emqx_channel.erl

@@ -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}};