Удалён никому ненужный SiteController

This commit is contained in:
ErickSkrauch 2016-05-31 21:11:11 +03:00
parent c3e7e99baa
commit 67fa28aaa1
2 changed files with 2 additions and 195 deletions

View File

@ -11,6 +11,7 @@ return [
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'bootstrap' => ['log'], 'bootstrap' => ['log'],
'controllerNamespace' => 'api\controllers', 'controllerNamespace' => 'api\controllers',
'params' => $params,
'components' => [ 'components' => [
'user' => [ 'user' => [
'identityClass' => \api\models\AccountIdentity::class, 'identityClass' => \api\models\AccountIdentity::class,
@ -26,9 +27,6 @@ return [
], ],
], ],
], ],
'errorHandler' => [
'errorAction' => 'site/error',
],
'request' => [ 'request' => [
'baseUrl' => '/api', 'baseUrl' => '/api',
], ],
@ -38,7 +36,7 @@ return [
'rules' => require __DIR__ . '/routes.php', 'rules' => require __DIR__ . '/routes.php',
], ],
'reCaptcha' => [ 'reCaptcha' => [
'class' => 'api\components\ReCaptcha\Component', 'class' => \api\components\ReCaptcha\Component::class,
], ],
'response' => [ 'response' => [
'format' => \yii\web\Response::FORMAT_JSON, 'format' => \yii\web\Response::FORMAT_JSON,
@ -48,5 +46,4 @@ return [
'grantTypes' => ['authorization_code'], 'grantTypes' => ['authorization_code'],
], ],
], ],
'params' => $params,
]; ];

View File

@ -1,190 +0,0 @@
<?php
namespace api\controllers;
use api\models\ContactForm;
use api\models\PasswordResetRequestForm;
use api\models\ResetPasswordForm;
use api\models\SignupForm;
use Yii;
use yii\base\InvalidParamException;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\BadRequestHttpException;
/**
* Site controller
*/
class SiteController extends \yii\web\Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'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,
]);
}
}