protected function btnLogin_Click($strFormId, $strControlId, $strParameter) { $objPerson = Person::LoadByUsername(trim(strtolower($this->txtUsername->Text))); if (!$objPerson) { $objPerson = Person::LoadByEmail(trim(strtolower($this->txtUsername->Text))); } if ($objPerson && $objPerson->IsPasswordValid($this->txtPassword->Text)) { QApplication::LoginPerson($objPerson); if ($this->chkRemember->Checked) { QApplication::SetLoginTicketToCookie($objPerson); } // Redirect to the correct location if ($objPerson->PasswordResetFlag) { if (array_key_exists('strReferer', $_GET)) { QApplication::Redirect('/profile/password.php?strReferer=' . urlencode($_GET['strReferer'])); } else { QApplication::Redirect('/profile/password.php?strReferer=' . urlencode('/')); } } else { if (array_key_exists('strReferer', $_GET)) { QApplication::Redirect($_GET['strReferer']); } else { QApplication::Redirect('/'); } } } // If we're here, either the username and/or password is not valid $this->txtUsername->Warning = 'Invalid username or password'; $this->txtPassword->Text = null; // Call Form_Validate() to do that blinking thing $this->Form_Validate(); }
/** * Called within prepend.inc.php to hidrate the $Person object into QApplication * if the person_id is stored in session (e.g. if a Person is logged in) * OR if a LoginTicket exists in the cookie * @return void */ public static function InitializePerson() { if (array_key_exists('intPersonId', $_SESSION)) { QApplication::$Person = Person::Load($_SESSION['intPersonId']); } else { if ($objTicket = QApplication::GetLoginTicketFromCookie()) { $objPerson = $objTicket->Person; QApplication::LoginPerson($objPerson); // Delete and Create New Ticket (to prevent ticket stealing) $objTicket->Delete(); QApplication::SetLoginTicketToCookie($objPerson); } } }
protected function btnRegister_Click($strFormId, $strControlId, $strParameter) { $this->mctPerson->Person->RegistrationDate = QDateTime::Now(); $this->mctPerson->Person->PersonTypeId = PersonType::RegisteredUser; $this->mctPerson->Person->SetPassword($this->txtPassword->Text); $this->mctPerson->SavePerson(); $this->mctPerson->Person->RefreshDisplayName(); QApplication::LoginPerson($this->mctPerson->Person); QApplication::Redirect('/register/confirmed.php'); }