EditPasswordController.class.php
1.32 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
50
51
52
53
54
55
56
57
58
<?php
/**
* 系统设置-修改密码
* CreateBy:何岳龙
* Date:2016年8月1日18:00:35
*/
namespace Apicp\Controller\SysSetting;
use Com\Validator;
use VcySDK\Adminer;
use VcySDK\Service;
class EditPasswordController extends AbstractController
{
public function Index()
{
// 新老密码
$pwd = I('post.pwd');
$oldPwd = I('post.oldPwd');
// 确认密码
$repeatPwd = I('post.repeatPwd');
// 密码不能为空
if (empty($pwd)) {
$this->_set_error('_ERR_PWD_EMPTY');
return false;
}
if (empty($oldPwd)) {
E('_ERR_OLD_PWD_EMPTY');
}
// 如果密码格式错误
if (! Validator::is_password($pwd)) {
$this->_set_error('_ERR_PWD_FORMAT');
return false;
}
// 登录密码和确认密码不相等
if ($pwd != $repeatPwd) {
$this->_set_error('_ERR_PWD_NOT_EQ');
return false;
}
// 初始化管理员
$sdk = new Adminer(Service::instance());
$sdk->modifyPWD([
'oldEaPassword' => $oldPwd,
'checkOldPassword' => Adminer::CHECK_OLD_PASSWORD_TRUE,
'eaPassword' => $pwd,
'eaId' => $this->_login->user['eaId']
]);
return true;
}
}