Explorar el Código

Merge pull request #6338 from tigercl/fix/superuser

fix(authn): fix superuser when missing is_superuser_field
tigercl hace 4 años
padre
commit
e888e1ef8d
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      apps/emqx_authn/src/simple_authn/emqx_authn_mongodb.erl

+ 3 - 1
apps/emqx_authn/src/simple_authn/emqx_authn_mongodb.erl

@@ -237,7 +237,9 @@ check_password(Password,
 
 
 is_superuser(Doc, #{is_superuser_field := IsSuperuserField}) ->
 is_superuser(Doc, #{is_superuser_field := IsSuperuserField}) ->
     IsSuperuser = maps:get(IsSuperuserField, Doc, false),
     IsSuperuser = maps:get(IsSuperuserField, Doc, false),
-    emqx_authn_utils:is_superuser(#{<<"is_superuser">> => IsSuperuser}).
+    emqx_authn_utils:is_superuser(#{<<"is_superuser">> => IsSuperuser});
+is_superuser(_, _) ->
+    emqx_authn_utils:is_superuser(#{<<"is_superuser">> => false}).
 
 
 hash(Algorithm, Password, Salt, prefix) ->
 hash(Algorithm, Password, Salt, prefix) ->
     emqx_passwd:hash(Algorithm, <<Salt/binary, Password/binary>>);
     emqx_passwd:hash(Algorithm, <<Salt/binary, Password/binary>>);