56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-4
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
|
|
namespace app\modules\store\controllers;
|
|
|
|
use app\modules\store\models\LoginForm;
|
|
|
|
|
|
class PassportController extends Controller
|
|
{
|
|
public $layout = 'passport';
|
|
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), []);
|
|
}
|
|
|
|
public function actions()
|
|
{
|
|
return [
|
|
'captcha' => \app\components\ResetCaptchaAction::className(),
|
|
];
|
|
}
|
|
|
|
public function actionLogin()
|
|
{
|
|
if (!\Yii::$app->store->isGuest && \Yii::$app->request->isGet) {
|
|
return $this->redirect(\Yii::$app->urlManager->createUrl(['store']));
|
|
}
|
|
$form = new LoginForm();
|
|
if (\Yii::$app->request->isPost) {
|
|
$form->attributes = \Yii::$app->request->post();
|
|
return $this->responseHandler($form->login());
|
|
} else {
|
|
return $this->render('login', [
|
|
'form' => $form
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function actionLogout()
|
|
{
|
|
\Yii::$app->store->logout();
|
|
\Yii::$app->response->redirect(\Yii::$app->urlManager->createUrl(['store']))->send();
|
|
\Yii::$app->end();
|
|
}
|
|
} |