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; }
protected function createComponentTable() { $session = $this->session; $admin = new AdminGrid($this->loginRepository); // columns $table = $admin->getTable(); if ($this->user->identity instanceof UserEntity) { $table->setModel(new Doctrine($this->loginRepository->createQueryBuilder('a')->andWhere('a.user = :user')->setParameter('user', $this->user->identity))); } else { $table->setModel(new Doctrine($this->loginRepository->createQueryBuilder('a')->andWhere('a.user IS NULL'))); } $table->setTranslator($this->translator); $table->addColumnDate('current', 'Current')->setCustomRender(function (LoginEntity $entity) use($session) { $el = Html::el('span'); $el->class[] = 'glyphicon ' . ($session->id == $entity->getSessionId() ? 'glyphicon-ok' : 'glyphicon-remove'); return $el; })->getCellPrototype()->width = '10%'; $table->addColumnDate('created', 'Date')->setSortable()->getCellPrototype()->width = '40%'; $table->addColumnText('sessionId', 'Session ID')->getCellPrototype()->width = '50%'; // actions $table->addAction('delete', 'Delete')->setConfirm(function ($entity) { return "Really delete session '{$entity->sessionId}'?"; })->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }