code: public function getBackendUsername(): ?string
      {
          $token = $this->getToken(BackendUser::SECURITY_SESSION_KEY);
  
          if (null === $token || !$token->getUser() instanceof BackendUser) {
              return null;
          }
  
          return $token->getUser()->getUsername();
      }
docs: Gets the back end username from the session.