[ 'class' => AccessControl::className(), //'only' => ['person'], 'rules' => [ [ 'actions' => ['person','captcha'], 'allow' => true, 'roles' => ['?'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ], ], ]; } public function actions() { return [ 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', ], ]; } private function saveUser($scenario = null){ $model = (!empty($_GET['id'])) ? Customer::findOne($_GET['id']) : new Customer; if(!empty($scenario))$model->scenario = $scenario; if ($model->load(Yii::$app->request->post())) { $model->role = "person"; $model->group_id = 1; $model->save(); $modelLogin = new LoginForm(); $modelLogin->username = $model->username; $modelLogin->password = $model->password; $modelLogin->login(); Mailer::widget( ['type' => 'registration', 'subject'=> 'Спасибо за регистрацию', 'email' => $model->username, 'params' => [ 'name' => $model->username, 'pass' => $model->password, ] ]); $this->redirect(['/iam']); } return $model; } public function actionPerson() { $model = $this->saveUser('person'); return $this->render('person', [ 'model' => $model, ]); } }