84 lines
1.5 KiB
PHP
84 lines
1.5 KiB
PHP
<?php
|
|
namespace mobileapi\controllers;
|
|
|
|
use Yii;
|
|
use yii\web\Controller;
|
|
use yii\filters\VerbFilter;
|
|
use yii\filters\AccessControl;
|
|
|
|
/**
|
|
* Site controller
|
|
*/
|
|
class SiteController extends Controller
|
|
{
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
'access' => [
|
|
'class' => AccessControl::className(),
|
|
'only' => ['logout' ],
|
|
'rules' => [
|
|
|
|
[
|
|
'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();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|