php class LoginController extends Controller public layout login publi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
class LoginController extends Controller
{
public $layout = 'login';
public function actionIndex()
{
$this->pageTitle = 'Авторизация';
$form = new LoginForm();
if (isset($_POST['LoginForm'])) {
$form->attributes = $_POST['LoginForm'];
if ($form->validate()) {
$form->login();
$this->redirect('/admin');
}
}
$this->render('index', array('form' => $form));
}
public function filters()
{
return array(
'accessControl',
);
}
public function accessRules()
{
return array(
array(
'allow',
'users' => array('?'),
),
array(
'deny',
'roles' => array('admin')
)
);
}
}