55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-4
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\controllers;
|
|
|
|
use app\modules\admin\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->admin->isGuest && \Yii::$app->request->isGet){
|
|
return $this->redirect(\Yii::$app->urlManager->createUrl(['admin']));
|
|
}
|
|
$form = new LoginForm();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
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->admin->logout();
|
|
\Yii::$app->response->redirect(\Yii::$app->urlManager->createUrl(['admin']))->send();
|
|
\Yii::$app->end();
|
|
}
|
|
} |