Skip to content

Commit

Permalink
后台创建账户密码问题的修复
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyecommerce committed Oct 28, 2019
1 parent 67b3a95 commit c6637d3
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions models/mysqldb/adminUser/AdminUserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public function rules()
['code', 'filter', 'filter' => 'trim'],
['code', 'validateCode'],
['person', 'filter', 'filter' => 'trim'],
['password', 'validatePasswordFormat'],
//['password', 'validatePasswordFormat'],
];

return array_merge($parent_rules,$current_rules) ;
}

public function validateUsername($attribute, $params){

if($this->id){
$one = AdminUser::find()->where(" id != ".$this->id." AND username = '".$this->username."' ")
->one();
Expand All @@ -47,6 +48,20 @@ public function validateUsername($attribute, $params){
$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){
Expand Down Expand Up @@ -80,20 +95,23 @@ public function validateEmail($attribute, $params){
}
}
}

/*
public function validatePasswordFormat($attribute, $params){
if($this->id){
if($this->password && strlen($this->password) <= 6){
$this->addError($attribute,"password must >=6");
}
}else{
if($this->password && strlen($this->password) >= 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 setPassword($password)
{
Expand Down

0 comments on commit c6637d3

Please sign in to comment.