public function actionRegistration() { // When we override the registrationUrl, this one should not be accessible // anymore if (Yum::module('registration')->registrationUrl != array('//registration/registration/registration')) { throw new CHttpException(403); } Yii::import('user.profile.models.*'); $form = new YumRegistrationForm(); $profile = new YumProfile(); $this->performAjaxValidation('YumRegistrationForm', $form); if (isset($_POST['YumRegistrationForm'])) { $form->attributes = $_POST['YumRegistrationForm']; $profile->attributes = $_POST['YumProfile']; if (Yum::module('registration')->registration_by_email) { $form->username = $profile->email; } $form->validate(); $profile->validate(); if (!$form->hasErrors() && !$profile->hasErrors()) { $user = new YumUser(); $user->register($form->username, $form->password, $profile); $user->profile = $profile; $this->sendRegistrationEmail($user); Yum::setFlash('Thank you for your registration. Please check your email.'); $this->redirect(Yum::module()->loginUrl); } } $this->render(Yum::module('registration')->registrationView, array('form' => $form, 'profile' => $profile)); }
public function actionRegistration() { // When we overrie the registrationUrl, this one is not valid anymore! if(Yum::module('registration')->registrationUrl != array( '//registration/registration/registration')) throw new CHttpException(403); Yii::import('application.modules.profile.models.*'); $form = new YumRegistrationForm; $profile = new YumProfile; $this->performAjaxValidation('YumRegistrationForm', $form); if (isset($_POST['YumRegistrationForm'])) { $form->attributes = $_POST['YumRegistrationForm']; $profile->attributes = $_POST['YumProfile']; $form->validate(); $profile->validate(); if(!$form->hasErrors() && !$profile->hasErrors()) { $user = new YumUser; $user->register($form->username, $form->password, $profile->email); $profile->user_id = $user->id; $profile->save(); $this->sendRegistrationEmail($user); Yum::setFlash('Thank you for your registration. Please check your email.'); $this->redirect(Yum::module()->loginUrl); } } $this->render(Yum::module()->registrationView, array( 'form' => $form, 'profile' => $profile, ) ); }