Пример #1
0
 public function actionRegister()
 {
     $coreProperties = $this->getCoreProperties();
     // Create Form Model
     $model = new Register();
     // Load and Validate Form Model
     if ($coreProperties->isRegistration() && $model->load(Yii::$app->request->post(), 'Register') && $model->validate()) {
         // Register User
         $user = UserService::register($model);
         if (isset($user)) {
             // Add User to current Site
             SiteMemberService::create($user);
             // Send Register Mail
             Yii::$app->cmgCoreMailer->sendRegisterMail($user);
             // Trigger Ajax Success
             return AjaxUtil::generateSuccess(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::MESSAGE_REGISTER));
         }
     }
     // Generate Errors
     $errors = AjaxUtil::generateErrorMessage($model);
     // Trigger Ajax Failure
     return AjaxUtil::generateFailure(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_REQUEST), $errors);
 }
Пример #2
0
 public function actionRegister()
 {
     // Send user to home if already logged in
     $this->checkHome();
     $coreProperties = $this->getCoreProperties();
     // Create Form Model
     $model = new Register();
     // Load and Validate Form Model
     if ($coreProperties->isRegistration() && $model->load(Yii::$app->request->post()) && $model->validate()) {
         // Register User
         $user = UserService::register($model);
         if (isset($user)) {
             // Add User to current Site
             SiteMemberService::create($user);
             // Send Register Mail
             Yii::$app->cmgCoreMailer->sendRegisterMail($user);
             // Set Flash Message
             Yii::$app->session->setFlash(CoreGlobal::FLASH_GENERIC, Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::MESSAGE_REGISTER));
             // Refresh the Page
             return $this->refresh();
         }
     }
     return $this->render(WebGlobalCore::PAGE_REGISTER, [CoreGlobal::MODEL_GENERIC => $model]);
 }