Пример #1
0
 public function actionSignup()
 {
     $model = new User();
     $model->setScenario('signup');
     if ($model->load($_POST) && $model->save()) {
         if (Yii::$app->getUser()->login($model)) {
             $this->redirect('index');
         }
     }
     return $this->render('signup', array('model' => $model));
 }
Пример #2
0
 public function actionSignup()
 {
     $model = new User();
     $model->setScenario('signup');
     if ($model->load($_POST) && $model->save()) {
         if (Yii::$app->getUser()->login($model)) {
             return $this->goHome();
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
Пример #3
0
 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new User();
     $model->setScenario('create_user');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $model->generatePasswordResetToken();
         $model->save(false);
         return $this->redirect(['view', 'id' => $model->id]);
     }
     $model->status = User::STATUS_ACTIVE;
     $model->group = User::GROUP_READER;
     return $this->render('create', ['model' => $model]);
 }
Пример #4
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signUp()
 {
     if ($this->validate(['username', 'password', 'confirm', 'email', 'mobile', 'group'])) {
         if ($this->password !== $this->confirm) {
             return null;
         }
         $user = new User();
         $user->setScenario('register');
         $user->username = $this->username;
         $user->email = $this->email;
         $user->mobile = $this->mobile;
         $user->status = User::STATUS_ACTIVE;
         $user->group = $this->group;
         $user->changed_password = true;
         $user->password_reset_token = Yii::$app->security->generateRandomString();
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }
Пример #5
0
 /**
  * Signs admin up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->setScenario("user-create");
         //            $user->username = $this->username;
         $user->created_by = $this->email;
         $user->modified_by = $this->email;
         $user->email = $this->email;
         $user->password = $this->password;
         $user->repassword = $this->repassword;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->first_name = $this->first_name;
         $user->last_name = $this->last_name;
         $user->mobile = $this->mobile;
         $user->status = self::STATUS_INACTIVE;
         $user->generateUserActivationCode();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }