提交 d1551220 编写于 作者: T Terry

admin user password

上级 5858fc3e
......@@ -27,7 +27,7 @@ class AdminUserForm extends AdminUser {
['code', 'filter', 'filter' => 'trim'],
['code', 'validateCode'],
['person', 'filter', 'filter' => 'trim'],
//['password', 'validatePasswordFormat'],
['password', 'validatePasswordFormat'],
];
return array_merge($parent_rules,$current_rules) ;
......@@ -48,20 +48,6 @@ class AdminUserForm extends AdminUser {
$this->addError($attribute,"this username is exist!");
}
}
// password
if($this->id){
if($this->password && strlen($this->password) <= 6){
$this->addError($attribute,"password must >=6");
}
}else{
if(!$this->password){
$this->addError($attribute,"password can not empty");
} else if (strlen($this->password) < 6) {
$this->addError($attribute,"password must >=6");
} else if (!strlen($this->password) >= 100) {
$this->addError($attribute,"password must <= 100");
}
}
}
public function validateCode($attribute, $params){
......@@ -95,7 +81,7 @@ class AdminUserForm extends AdminUser {
}
}
}
/*
public function validatePasswordFormat($attribute, $params){
if($this->id){
if($this->password && strlen($this->password) <= 6){
......@@ -111,7 +97,7 @@ class AdminUserForm extends AdminUser {
}
}
}
*/
public function setPassword($password)
{
......
......@@ -162,6 +162,11 @@ class AdminUser extends Service
if (!$data['auth_key']) {
$this->_userFormModel->auth_key = '';
}
if (!$data['password'] && !$data['id']) {
Yii::$service->helper->errors->add("password can not empty");
return null;
}
if ($this->_userFormModel[$primaryKey]) {
if ($this->_userFormModel->validate()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册