/** * Called when user wishes to logout. * Calls \model\LoginModel to destroy session, and * \view\LoginView to delete cookies. * * Sets \view\LoginView message. */ public function logout() { if ($this->logModel->isLoggedIn()) { $this->logModel->logout(); $this->logView->deleteCredentialCookies(); $this->logView->setMsgLogout(); } }
/** * Handle user input */ public function listen() { if ($this->logView->isRegisteredCookieSet()) { $this->logView->setMsgRegistered(); $this->logView->deleteRegisteredCookie(); if ($this->logView->isCookieNameSet()) { $this->logView->setLoginName($this->logView->getCookieName()); } } // Login if ($this->logView->loginButtonPost() && !$this->logModel->isLoggedIn()) { try { $this->login(); } catch (LUsernameMissingException $e) { $this->logView->setMsgUsernameMissing(); } catch (LPasswordMissingException $e) { $this->logView->setMsgPasswordMissing(); } catch (LUsernameOrPasswordException $e) { $this->logView->setMsgUsernameOrPassword(); } } else { if ($this->logView->logoutButtonPost() && $this->logModel->isLoggedIn()) { $this->logModel->logout(); $this->logView->deleteCredentialCookies(); } else { if ($this->logView->isPost()) { $this->logView->redirect(); } else { if ($this->logView->isCookiesSet()) { try { $this->cookieLogin(); } catch (LWrongCookieInformationException $e) { $this->logView->deleteCredentialCookies(); $this->logView->setMsgWrongCookieInfo(); } } } } } }