public function main()
 {
     $_user = User::findByVerificationToken($this->_pdo, $_GET["t"]);
     if (is_null($_user)) {
         $this->setError(self::$E_TOKEN_INVALID);
         return;
     }
     if ($_user->isTokenExpiredAccountVerify()) {
         $_user->reissueVerificationToken();
         $worker = new EmailWorker($this->_pdo);
         $worker->queueUserConfirmationEmail($_user);
         $this->setError(self::$E_TOKEN_EXPIRED);
         return;
     }
     $_user->verifyAccount();
 }
Esempio n. 2
0
 public function authenticate(\string $email, \string $password)
 {
     if ($this->isLoggedIn()) {
         Utility::displayPage("/account/");
     }
     if (!is_null($this->_remember)) {
         if ($this->_remember->isExpired()) {
             $this->_remember->remove();
         } else {
             $this->_remember->update();
             $this->login($this->_remember->getUser());
             return;
         }
     }
     if ($email == "" || $password == "") {
         $this->setError(self::$ERROR_INVALID_CREDENTIALS);
         return;
     }
     if (!Utility::stringContains($email, ["@", "."])) {
         $this->setError(self::$ERROR_EMAIL_INVALID);
         return;
     }
     $_user = User::findByEmail($this->_pdo, $email);
     if (is_null($_user)) {
         $this->setError(self::$ERROR_USER_DNE);
     } else {
         if ($_user->isGraduated()) {
             $this->setError(self::$ERROR_USER_NO_LONGER_ACTIVE);
         } else {
             if ($_user->getTokenAccountVerify()) {
                 $this->setError(self::$ERROR_USER_NOT_VERIFIED);
                 if ($_user->isTokenExpiredAccountVerify()) {
                     $_user->reissueVerificationToken();
                 }
                 $worker = new EmailWorker($this->_pdo);
                 $worker->queueUserConfirmationEmail($_user);
             } else {
                 if (!Utility::verifyPassword($password, $_user->getPasswordHash())) {
                     $this->setError(self::$ERROR_INVALID_CREDENTIALS);
                 } else {
                     $this->login($_user);
                 }
             }
         }
     }
 }