code: protected function beforeLogout($identity)
      {
          $event = new UserEvent([
              'identity' => $identity,
          ]);
          $this->trigger(self::EVENT_BEFORE_LOGOUT, $event);
  
          return $event->isValid;
      }
docs: This method is invoked when calling [[logout()]] to log out a user.
  The default implementation will trigger the [[EVENT_BEFORE_LOGOUT]] event.
  If you override this method, make sure you call the parent implementation
  so that the event is triggered.
  @param IdentityInterface $identity the user identity information
  @return bool whether the user should continue to be logged out