/** * Captcha-authenticated registration. Used by default. * * Allows immediate access upon successful registration, and optionally requires * email address confirmation. * * Events: RegistrationSuccessful * * @access private * @since 2.0.0 */ private function registerBasic() { $this->View = 'registerbasic'; Gdn::userModel()->addPasswordStrength($this); if ($this->Form->isPostBack() === true) { // Add validation rules that are not enforced by the model $this->UserModel->defineSchema(); $this->UserModel->Validation->applyRule('Name', 'Username', $this->UsernameError); $this->UserModel->Validation->applyRule('TermsOfService', 'Required', t('You must agree to the terms of service.')); $this->UserModel->Validation->applyRule('Password', 'Required'); $this->UserModel->Validation->applyRule('Password', 'Strength'); $this->UserModel->Validation->applyRule('Password', 'Match'); // $this->UserModel->Validation->applyRule('DateOfBirth', 'MinimumAge'); $this->fireEvent('RegisterValidation'); try { $Values = $this->Form->formValues(); $Values = $this->UserModel->filterForm($Values, true); unset($Values['Roles']); $AuthUserID = $this->UserModel->register($Values); $this->setData('UserID', $AuthUserID); if ($AuthUserID == UserModel::REDIRECT_APPROVE) { $this->Form->setFormValue('Target', '/entry/registerthanks'); $this->_setRedirect(); return; } elseif (!$AuthUserID) { $this->Form->setValidationResults($this->UserModel->validationResults()); } else { // The user has been created successfully, so sign in now. Gdn::session()->start($AuthUserID); if ($this->Form->getFormValue('RememberMe')) { Gdn::authenticator()->setIdentity($AuthUserID, true); } try { $this->UserModel->sendWelcomeEmail($AuthUserID, '', 'Register'); } catch (Exception $Ex) { } $this->fireEvent('RegistrationSuccessful'); // ... and redirect them appropriately $Route = $this->redirectTo(); if ($this->_DeliveryType != DELIVERY_TYPE_ALL) { $this->RedirectUrl = url($Route); } else { if ($Route !== false) { redirect($Route); } } } } catch (Exception $Ex) { $this->Form->addError($Ex); } } $this->render(); }