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(); }
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); } } } } }
public function main() { $org_id = Utility::cleanInt($_POST["org_id"], 1); $uni_id = Utility::cleanInt($_POST["uni_id"], 1); $email = Utility::cleanString($_POST["university_email"]); $name_first = Utility::cleanString($_POST["name_first"]); $name_last = Utility::cleanString($_POST["name_last"]); $password = Utility::cleanString($_POST["password"]); $pledge_class = Utility::cleanString($_POST["pledge_class"]); $year = Utility::getDateTimeFromYear(Utility::cleanString($_POST["year"])); if (!$org_id) { $this->setError(self::$E_ORG_INVALID); return; } if (!$uni_id) { $this->setError(self::$E_UNI_INVALID); return; } $_org = GreekOrganization::find($this->_pdo, $org_id); $_uni = University::find($this->_pdo, $uni_id); if (is_null($_org)) { $this->setError(self::$E_ORG_INVALID); return; } if (is_null($_uni)) { $this->setError(self::$E_UNI_INVALID); return; } if (Chapter::findByOrgAndUni($this->_pdo, $_org, $_uni)) { $this->setError(self::$E_CHAPTER_EXISTS); return; } if ($name_first == "") { $this->setError(self::$E_NAME_F_INVALID); return; } if ($name_last == "") { $this->setError(self::$E_NAME_L_INVALID); return; } if (!Utility::isValidEmail($email)) { $this->setError(self::$E_EMAIL_INVALID); return; } if (User::findByEmail($this->_pdo, $email)) { $this->setError(self::$E_USER_EXISTS); return; } if ($pledge_class == "") { $this->setError(self::$E_PLEDGE_CLASS_INVALID); return; } if (!Utility::cleanInt($_POST["year"], date("Y") - 6)) { $this->setError(self::$E_YEAR_INVALID); return; } if ($year === false) { $this->setError(self::$E_YEAR_INVALID); return; } if (!Utility::isValidPassword($password)) { $this->setError(self::$E_PASSWORD_INVALID); return; } $_chapter = new Chapter($this->_pdo); $_chapter->create($_org, $_uni); $_pc = new PledgeClass($this->_pdo); $_pc->create($_chapter, $pledge_class); $_user = new User($this->_pdo); $_user->create($_chapter, $_pc, $name_first, $name_last, $email, $password, $year, true); $worker = new EmailWorker($this->_pdo); //TODO: Send email to user about what's next $worker->queueSignUpNotificationEmail($_chapter); }