protected function Form_Create() { parent::Form_Create(); if (QApplication::GetUserId() == NarroUser::ANONYMOUS_USER_ID) { $strPassHash = QApplication::QueryString('h'); $strUsername = QApplication::QueryString('u'); if ($strPassHash && $strUsername) { $objUser = NarroUser::LoadByUsernameAndPassword($strUsername, $strPassHash); if ($objUser instanceof NarroUser) { QApplication::$User = $objUser; } else { QApplication::Redirect('login.php'); } } else { QApplication::Redirect('login.php'); } } $this->lblMessage = new QLabel($this); $this->lblMessage->HtmlEntities = false; $this->txtPassword = new QTextBox($this); $this->txtPassword->TextMode = QTextMode::Password; $this->btnChangePassword = new QButton($this); $this->btnChangePassword->PrimaryButton = true; $this->btnChangePassword->Text = t('Change password'); $this->btnChangePassword->AddAction(new QClickEvent(), new QServerAction('btnChangePassword_Click')); }
public static function RegisterUser($strUsername, $strEmail, $strPassword, $strRealName) { $objMaxUser = NarroUser::LoadAll(QQ::Clause(QQ::LimitInfo(1, 0), QQ::OrderBy(QQN::NarroUser()->UserId, false))); $objUser = new NarroUser(); $objUser->UserId = $objMaxUser[0]->UserId + 1; $objUser->Username = $strUsername; if ($strRealName) { $objUser->RealName = $strRealName; } $objUser->Email = $strEmail; require_once __NARRO_INCLUDES__ . '/PasswordHash.class.php'; $objHasher = new PasswordHash(8, FALSE); $objUser->Password = $objHasher->HashPassword($strPassword); try { $objUser->Save(); } catch (Exception $objEx) { throw $objEx; } /** * set up default roles */ $objUserRole = new NarroUserRole(); if ($objUser->UserId == 1) { $objUserRole->RoleId = 5; } else { $objUserRole->RoleId = 2; } $objUserRole->UserId = $objUser->UserId; $objUserRole->Save(); return NarroUser::LoadByUsernameAndPassword($strUsername, md5($strPassword)); }