diff --git a/models/mysqldb/adminUser/AdminUserForm.php b/models/mysqldb/adminUser/AdminUserForm.php index 5d58003fca3f95f92c0b43106b1637e49c194e36..21ac01f7b20aa3dd0e63807d86d502d397e470e9 100644 --- a/models/mysqldb/adminUser/AdminUserForm.php +++ b/models/mysqldb/adminUser/AdminUserForm.php @@ -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) { diff --git a/services/adminUser/AdminUser.php b/services/adminUser/AdminUser.php index 85f42202743ba91dd6adb3c2a8d6e146f54345d5..ed5cee91f6296d4b6cfc3458529de87e0a26de70 100644 --- a/services/adminUser/AdminUser.php +++ b/services/adminUser/AdminUser.php @@ -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()) {