From 67fa28aaa1c8feec12e62a655e7581845e6d5453 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 31 May 2016 21:11:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D1=91=D0=BD=20=D0=BD?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=BC=D1=83=20=D0=BD=D0=B5=D0=BD=D1=83=D0=B6?= =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20SiteController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/config/main.php | 7 +- api/controllers/SiteController.php | 190 ----------------------------- 2 files changed, 2 insertions(+), 195 deletions(-) delete mode 100644 api/controllers/SiteController.php diff --git a/api/config/main.php b/api/config/main.php index ff3af4c..a588dc8 100644 --- a/api/config/main.php +++ b/api/config/main.php @@ -11,6 +11,7 @@ return [ 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'api\controllers', + 'params' => $params, 'components' => [ 'user' => [ 'identityClass' => \api\models\AccountIdentity::class, @@ -26,9 +27,6 @@ return [ ], ], ], - 'errorHandler' => [ - 'errorAction' => 'site/error', - ], 'request' => [ 'baseUrl' => '/api', ], @@ -38,7 +36,7 @@ return [ 'rules' => require __DIR__ . '/routes.php', ], 'reCaptcha' => [ - 'class' => 'api\components\ReCaptcha\Component', + 'class' => \api\components\ReCaptcha\Component::class, ], 'response' => [ 'format' => \yii\web\Response::FORMAT_JSON, @@ -48,5 +46,4 @@ return [ 'grantTypes' => ['authorization_code'], ], ], - 'params' => $params, ]; diff --git a/api/controllers/SiteController.php b/api/controllers/SiteController.php deleted file mode 100644 index 716f003..0000000 --- a/api/controllers/SiteController.php +++ /dev/null @@ -1,190 +0,0 @@ - [ - 'class' => AccessControl::className(), - 'only' => ['logout', 'signup'], - 'rules' => [ - [ - 'actions' => ['signup'], - 'allow' => true, - 'roles' => ['?'], - ], - [ - 'actions' => ['logout'], - 'allow' => true, - 'roles' => ['@'], - ], - ], - ], - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'logout' => ['post'], - ], - ], - ]; - } - - /** - * @inheritdoc - */ - public function actions() - { - return [ - 'error' => [ - 'class' => 'yii\web\ErrorAction', - ], - 'captcha' => [ - 'class' => 'yii\captcha\CaptchaAction', - 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, - ], - ]; - } - - /** - * Displays homepage. - * - * @return mixed - */ - public function actionIndex() - { - return $this->render('index'); - } - - /** - * Logs out the current user. - * - * @return mixed - */ - public function actionLogout() - { - Yii::$app->user->logout(); - - return $this->goHome(); - } - - /** - * Displays contact page. - * - * @return mixed - */ - public function actionContact() - { - $model = new ContactForm(); - if ($model->load(Yii::$app->request->post()) && $model->validate()) { - if ($model->sendEmail(Yii::$app->params['adminEmail'])) { - Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); - } else { - Yii::$app->session->setFlash('error', 'There was an error sending email.'); - } - - return $this->refresh(); - } else { - return $this->render('contact', [ - 'model' => $model, - ]); - } - } - - /** - * Displays about page. - * - * @return mixed - */ - public function actionAbout() - { - return $this->render('about'); - } - - /** - * Signs user up. - * - * @return mixed - */ - public function actionSignup() - { - $model = new SignupForm(); - if ($model->load(Yii::$app->request->post())) { - if ($user = $model->signup()) { - if (Yii::$app->getUser()->login($user)) { - return $this->goHome(); - } - } - } - - return $this->render('signup', [ - 'model' => $model, - ]); - } - - /** - * Requests password reset. - * - * @return mixed - */ - public function actionRequestPasswordReset() - { - $model = new PasswordResetRequestForm(); - if ($model->load(Yii::$app->request->post()) && $model->validate()) { - if ($model->sendEmail()) { - Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); - - return $this->goHome(); - } else { - Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); - } - } - - return $this->render('requestPasswordResetToken', [ - 'model' => $model, - ]); - } - - /** - * Resets password. - * - * @param string $token - * @return mixed - * @throws BadRequestHttpException - */ - public function actionResetPassword($token) - { - try { - $model = new ResetPasswordForm($token); - } catch (InvalidParamException $e) { - throw new BadRequestHttpException($e->getMessage()); - } - - if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { - Yii::$app->session->setFlash('success', 'New password was saved.'); - - return $this->goHome(); - } - - return $this->render('resetPassword', [ - 'model' => $model, - ]); - } -}