public function render() { $diagrams = $this->diagramRepository->getByUser($this->auth->getUser()); $idToDelete = $this->myDiagramsView->shouldDelete(); if ($idToDelete != null) { foreach ($diagrams as $index => $diagram) { if ($diagram->getId() == $idToDelete) { $this->diagramRepository->delete($diagram); unset($diagrams[$index]); } } } $this->myDiagramsView->setDiagrams($diagrams); return $this->myDiagramsView; }
/** * @return LoginView|UserView */ public function render() { if ($this->auth->isLoggedIn() && $this->userView->haveLoggedOut()) { $this->auth->logOut(); $this->credentialsHandler->deleteSecret(); $this->router->redirectTo(Router::INDEX); } elseif (!$this->auth->isLoggedIn()) { if ($this->loginView->haveLoggedIn()) { $username = $this->loginView->getUsername(); $password = $this->loginView->getPassword(); if ($this->auth->logInByCredentials($username, $password)) { $token = new Token($this->auth->getUser()); $this->tokenRepository->insert($token); $this->credentialsHandler->saveSecret($token); $this->router->redirectTo(Router::INDEX); } else { $this->loginView->loginFailed(); } } elseif ($this->credentialsHandler->hasSecret()) { $secret = $this->credentialsHandler->getSecret(); try { $token = $this->tokenRepository->getBySecret($secret); $this->auth->logInByToken($token); $this->router->redirectTo(Router::INDEX); } catch (\Exception $e) { } } } if ($this->auth->isLoggedIn()) { return $this->userView; } else { return $this->loginView; } }