Beispiel #1
0
 public function actionRegister()
 {
     $model = new RegisterForm();
     if ($model->load(\Yii::$app->request->post())) {
         $data = new TAccount();
         $data->name = $model->account;
         $data->email = $model->email;
         $data->sc = md5($model->sc);
         $data->pwd = md5($model->password);
         $data->pw2 = md5($model->pwd2);
         if ($data->save()) {
             Yii::$app->session->setFlash('success', 'Tạo tài khoản thành công');
             return $this->redirect('dang-nhap.html');
         } else {
             $error = '';
             foreach ($data->errors as $val) {
                 foreach ($val as $value) {
                     $error .= $value . '<br/>';
                 }
             }
             Yii::$app->session->setFlash('error', $error);
         }
     }
     return $this->render('register', ['model' => $model]);
 }
 /**
  * @inheritdoc
  */
 public function actionRegister()
 {
     $model = new RegisterForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $registerStatus = $model->register();
     } else {
         return $this->render('register', ['model' => $model]);
     }
 }
 public function actionRegister()
 {
     $model = new RegisterForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->register()) {
             if (Yii::$app->getUser()->login($user)) {
                 return $this->goHome();
             }
         }
     }
     return $this->render('register', ['model' => $model]);
 }
Beispiel #4
0
 /**
  * @inheritdoc
  */
 public function actionRegister()
 {
     $model = new RegisterForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->RegisterType = 3;
         $registerStatus = $model->register();
         Yii::$app->getSession()->setFlash('success', 'Successfully Registered.');
         // 	if ($model->sendEmail()) {
         //                 Yii::$app->getSession()->setFlash('success', 'Successfully Registered.');
         //             } else {
         //                 Yii::$app->getSession()->setFlash('error', 'Sorry, we are unable to reset password for email provided.');
         //             }
         //echo "Registration successfully";
         return $this->render('register', ['model' => $model]);
     }
     return $this->render('register', ['model' => $model]);
 }
 public function actionRegister()
 {
     $model = Yii::createObject(RegisterForm::className());
     if ($model->load(Yii::$app->request->post()) && $model->register()) {
         Yii::$app->user->login($model->user);
         return $this->goHome();
     }
     return $this->render('register', compact('model'));
 }
 /**
  * /register
  *
  * @return string|\yii\web\Response
  */
 public function actionIndex()
 {
     if ($this->member) {
         return $this->goHome();
     }
     if (!$this->params['registrationsOpen']) {
         $this->notifyError('Registrations are currently closed');
         return $this->goHome();
     }
     $model = new RegisterForm();
     $errors = null;
     if ($this->request->method == 'POST') {
         // populate model attributes with user inputs
         $model->load($this->request->post());
         if ($model->validate() && $model->register()) {
             $this->notifySuccess('Complete your registration by opening the email sent to ' . $model->email);
             return $this->redirect('/login');
         } else {
             // validation failed: $errors is an array containing error messages
             $errors = $model->errors;
         }
     }
     return $this->render('index', ['model' => $model, 'errors' => $errors]);
 }
 public function actionFinishRegister($uid)
 {
     $registerModel = new RegisterForm(['scenario' => 'finishRegister']);
     if (Yii::$app->request->isAjax && $registerModel->load($_POST)) {
         Yii::$app->response->format = 'json';
         return \yii\widgets\ActiveForm::validate($registerModel);
     }
     if ($registerModel->load(Yii::$app->request->post())) {
         $user = $registerModel->finishRegister($uid);
         if ($user) {
             Yii::$app->session->setFlash('alert', '完成注册成功');
             Yii::$app->session->setFlash('alert-type', 'alert-success');
             if (Yii::$app->getUser()->login($user, 3600 * 24)) {
                 return $this->goHome();
             }
         } else {
             Yii::$app->session->setFlash('alert', '完成注册失败');
             Yii::$app->session->setFlash('alert-type', 'alert-danger');
             return $this->goHome();
         }
     } else {
         $newUser = User::findByUserId($uid, User::STATUS_WAITFINISH);
         if ($newUser) {
             $registerModel->email = $newUser->email;
             $registerModel->username = $newUser->username;
             $registerModel->avatar = $newUser->avatar;
         } else {
             throw new InvalidCallException('user need not to be finished');
         }
     }
     return $this->render('register', ['model' => $registerModel, 'title' => '完成注册']);
 }
 public function testNotCorrectSignup()
 {
     $model = new RegisterForm(['username' => 'troy.becker', 'email' => '*****@*****.**', 'password' => 'some_password']);
     expect('username and email are in use, user should not be created', $model->register())->null();
 }
 public function actionRegister()
 {
     $model = new RegisterForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         return $this->render('congratulations');
     }
     return $this->render('register', ['model' => $model]);
 }