/** * @return bool * @throws InvalidStateException */ public function isAuthenticated() { $authenticated = parent::isAuthenticated(); if ($this->users === NULL) { throw new InvalidStateException('Service IUsers is not registered.'); } if ($this->authenticated === NULL || $this->authenticated !== $authenticated) { if ($authenticated === true) { $identity = $this->getIdentity(); if (!$this->users->validateToken($identity->getToken(), $identity->getUser())) { $this->getSessionSection(true)->remove(); // Logout $authenticated = false; } } $this->authenticated = $authenticated; } return $this->authenticated; }