SiteController.php 579 Bytes
Newer Older
1 2
<?php

3
namespace backend\controllers;
4 5 6

use Yii;
use yii\web\Controller;
7
use common\models\LoginForm;
8 9 10 11 12

class SiteController extends Controller
{
	public function actionIndex()
	{
13
		return $this->render('index');
14 15 16 17 18
	}

	public function actionLogin()
	{
		$model = new LoginForm();
19 20
		if ($model->load($_POST) && $model->login()) {
			return $this->redirect(array('site/index'));
21
		} else {
22
			return $this->render('login', array(
23 24 25 26 27 28 29
				'model' => $model,
			));
		}
	}

	public function actionLogout()
	{
30
		Yii::$app->user->logout();
31
		return $this->redirect(array('site/index'));
32 33
	}
}