Index.php
1.93 KB
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
44
45
46
47
48
49
<?php
use Action\RootAction;
use Hood\Cache;
use QAdmin\Profile\Client as ProfileClient;
use Hood\Core\Security\AuthCode;
use QAdmin\Config as QAdminConfig;
use QAdmin\Session\Client as SessionClient;
class IndexController extends RootAction
{
public function indexAction()
{
$this->getView()->setLayout('signin');
$this->_viewLink()->offsetSetFile(100, $this->_css('style.default', true));
$this->_viewScript()->conditional('lt IE 9')
->offsetSetFile(100, $this->_js('html5shiv', true))
->offsetSetFile(101, $this->_js('respond', true));
$this->_viewLink()->offsetSetFile(200, $this->_css('debugbar', true));
}
public function signinAction()
{
$this->disableView();
$account = $this->_post('account');
$password = $this->_post('password');
$validator = $this->validator(
['account' => $account, 'password' => $password],
['account' => 'required', 'password' => 'required']
);
if ($validator->fails() == true) {
$this->helpJsRedirect($validator->errors()->first());
}
$accountInfo = ProfileClient::self()->Dao()->getProfileByAccount($account);
if (empty($accountInfo)) {
$this->helpJsRedirect('没有这个账号.');
}
$authPass = AuthCode::authPassword($password, $accountInfo['password']);
if ($authPass == false) {
$this->helpJsRedirect('密码错误.');
}
if ($accountInfo['expiration'] > QAdminConfig::$expiration) {
$this->helpJsRedirect('你账号 ' . QAdminConfig::$expiration . ' 天没有登陆,已经冻结.');
}
$accountInfo['token'] = $token = md5(uniqid('profile_info', true));
SessionClient::self()->Dao()->setSession($accountInfo['pid'], $token);
$this->_session('adminx_profile')->__set('profile_info', $accountInfo);
$this->redirect('/display');
}
}