/**
  * 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();
     }
 }
Ejemplo n.º 2
0
 private function login()
 {
     try {
         $user = $this->loginView->getUser();
         if ($user == null) {
             return;
         }
         $this->loginModel->tryLoginUser($user);
         $this->loginView->setLoginSucceeded();
     } catch (\WrongCredentialsException $e) {
         $this->loginView->setLoginFailed();
     }
 }