private function logout() { $this->loginModel->logoutUser(); $this->loginView->forgetUser(); $this->loginView->setLogoutSucceeded(); $this->loginView->reloadPage(); }
public function render($isLoggedIn, LoginView $v, DateTimeView $dtv) { echo '<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Login Example</title> </head> <body> <h1>Assignment 2</h1> ' . $this->renderIsLoggedIn($isLoggedIn) . ' <div class="container"> ' . $v->response() . ' ' . $dtv->show() . ' </div> </body> </html> '; }
/** * @return BootstrapView * @LogInNotPermitted */ public function promptAction() { if ($this->router->getRequestAnalyzer()->getRequestMethod() == "POST" && self::$numberOfLoginsInCurrentRequest == 0) { $user = $this->router->getRequestAnalyzer()->getPostRequest()["user"]; $password = $this->router->getRequestAnalyzer()->getPostRequest()["password"]; self::$numberOfLoginsInCurrentRequest++; try { $this->router->getApplicationRoot()->getAuthenticator()->authenticate($user, $password); $userObject = $this->router->getApplicationRoot()->getUserDAO()->getUserByUsername($user); $this->router->getApplicationSession()->setUser($userObject); } catch (UnauthorizedException $e) { //$this->router->getApplicationSession()->setAlert(BootstrapAlert::WARNING("Login failed.")); //$this->router->reRouteTo("main", "default"); } $this->router->rewindAndRestartRouting(); } else { $view = new LoginView(); $view->setHeaderText("Awesome Inc."); $view->setBadge("Intranet"); return BootstrapView::getLoginPage("", $view); } }
/** * Check if user has clicked 'Register a new user' link. * * @return boolean */ public function registerLinkPressed() { return $this->logView->registerLinkPressed(); }
/** * Function for handling states associated with the login */ public function doLogin() { //var_dump(self::$LoginView->isCorrectSession()); if (self::$LoginView->theUserWantToLogout()) { self::$LoginView->setLogoutView(); self::$LoginModel->logout(); $tempUsername = self::$LoginView->removeKeepLogin(); self::$LoginModel->removeUser($tempUsername); } else { if (self::$LoginView->theUserWantToLogin()) { self::$LoginView->setLoginView(); $successfulLogin = self::$LoginModel->login(self::$LoginView->getUser()); if ($successfulLogin && self::$LoginView->isKeepLoggedInChecked()) { $randomizedPassword = self::$LoginModel->saveUser(self::$LoginView->getUser()); self::$LoginView->setKeepLogin($randomizedPassword); } } else { if (self::$LoginView->checkIfPersistentLoggedIn()) { self::$LoginModel->loginSavedUser(self::$LoginView->getPersistentLoggedInUser()); self::$LoginView->setLoginWithCookiesView(); } else { if (!self::$LoginView->validCookies()) { // self::$LoginModel->logout(); self::$LoginView->removeKeepLogin(); self::$LoginView->setFailedLoginWithCookiesView(); } } } } if (self::$PrgView->isPost()) { self::$PrgView->reloadPage(); } }