public function isAuthenticated() { if (($ret = parent::isAuthenticated()) === FALSE) { return FALSE; } if (($identity = $this->getIdentity()) === NULL) { return FALSE; } if ($identity instanceof UserEntity) { if (!isset($this->logins[$this->session->id][$identity->id])) { $this->logins[$this->session->id][$identity->id] = (bool) $this->loginRepository->findOneBy(array('user' => $identity->id, 'sessionId' => $this->session->id)); } return $this->logins[$this->session->id][$identity->id]; } else { if ($this->checkConnection->invoke()) { try { if (!isset($this->logins[$this->session->id][-1])) { $this->logins[$this->session->id][-1] = (bool) $this->loginRepository->findOneBy(array('user' => NULL, 'sessionId' => $this->session->id)); if (!$this->logins[$this->session->id][-1]) { $this->setAuthenticated(TRUE); } } return TRUE; } catch (DBALException $e) { } } } return $ret; }
/** * @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; }