_service = $service; } public function behaviors(): array { return [ 'access' => [ 'class' => AccessControl::class, //'only' => ['index'], 'rules' => [ [ 'actions' => ['request', 'confirm'], 'allow' => true, 'roles' => ['?'], ], ], ], ]; } /** * @return mixed */ public function actionRequest() { $form = new SignupForm(); if ($form->load(Yii::$app->request->post()) && $form->validate()) { try { $this->_service->signup($form); Yii::$app->session->setFlash('success', Yii::t('auth', 'Check your email for further instructions.')); //return $this->goHome(); return $this->redirect(['auth/auth/login']); } catch (\DomainException $e) { Yii::$app->errorHandler->logException($e); Yii::$app->session->setFlash('error', $e->getMessage()); } } return $this->render('request', [ 'model' => $form, ]); } /** * @param $token * * @return mixed */ public function actionConfirm($token) { try { $this->_service->confirm($token); Yii::$app->session->setFlash('success', Yii::t('auth', 'Your email is confirmed.')); return $this->redirect(['auth/auth/login']); } catch (\DomainException $e) { Yii::$app->errorHandler->logException($e); Yii::$app->session->setFlash('error', $e->getMessage()); } return $this->goHome(); } }