Пример #1
0
 public function beforeAction($action)
 {
     // if(Yii::$app->website->is_trade)
     //       {
     //           if( !Yii::$app->user->isLoggedIn() ) {
     //               Yii::$app->user->loginRequired();
     //               return false;
     //           } elseif( Yii::$app->user->customer->is_trade !== 'A' ) {
     //               Yii::$app->user->logout();
     //           }
     //       }
     if (User::find()->count() == 0) {
         return $this->owner->redirect(['/user/registration/register']);
         exit;
     }
     return parent::beforeAction($action);
 }
Пример #2
0
 /**
  * Creates a new User model.
  * If creation is successful, the browser will be redirected to the 'index' page.
  *
  * @return mixed
  */
 public function actionCreate()
 {
     /** @var User $user */
     $user = Yii::createObject(['class' => User::className(), 'scenario' => 'create']);
     $event = $this->getUserEvent($user);
     $this->performAjaxValidation($user);
     $this->trigger(self::EVENT_BEFORE_CREATE, $event);
     if ($user->load(Yii::$app->request->post()) && $user->create()) {
         Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User has been created'));
         $this->trigger(self::EVENT_AFTER_CREATE, $event);
         return $this->redirect(['update', 'id' => $user->id]);
     }
     return $this->render('create', ['user' => $user]);
 }
Пример #3
0
 /**
  * Loads attributes to the user model. You should override this method if you are going to add new fields to the
  * registration form. You can read more in special guide.
  *
  * By default this method set all attributes of this model to the attributes of User model, so you should properly
  * configure safe attributes of your User model.
  *
  * @param User $user
  */
 protected function loadAttributes(User $user)
 {
     $user->setAttributes($this->attributes);
 }