@Override
  public boolean checkUserPrivileges(String userName, PrivilegeUnion union) throws AuthException {
    if (isAdmin(userName)) {
      return true;
    }
    User user = userManager.getEntity(userName);
    if (user == null) {
      throw new AuthException(
          TSStatusCode.USER_NOT_EXIST, String.format(NO_SUCH_USER_EXCEPTION, userName));
    }
    if (checkEntityPrivileges(user, union)) {
      return true;
    }

    for (String roleName : user.getRoleSet()) {
      Role role = roleManager.getEntity(roleName);
      if (checkEntityPrivileges(role, union)) {
        return true;
      }
    }
    return false;
  }
Checks if a user has admin privileges
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/auth/authorizer/BasicAuthorizer.java