refactor: 修改用户更新场景密码验证问题
This commit is contained in:
@@ -207,10 +207,10 @@ class User
|
||||
'role_id',
|
||||
'status' => 1,
|
||||
]);
|
||||
$data = array_merge($put, ['id' => $id, 'salt' => random_str(16)]);
|
||||
$data = array_merge($put, ['id' => $id]);
|
||||
|
||||
$validate = new SysUserValidate;
|
||||
if (!$validate->check($data)) {
|
||||
if (!$validate->scene('update')->check($data)) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
|
||||
@@ -220,6 +220,7 @@ class User
|
||||
}
|
||||
|
||||
if (!empty($data['password'])) {
|
||||
$data['salt'] = random_str(16);
|
||||
$data['password'] = password_with_salt($data['password'], $data['salt']);
|
||||
} else {
|
||||
unset($data['password']);
|
||||
|
||||
@@ -63,6 +63,8 @@ class SysUserValidate extends Validate
|
||||
// 更新校验场景
|
||||
public function sceneUpdate()
|
||||
{
|
||||
return $this->remove('repassword', 'requireWith:password|confirm:password');
|
||||
return $this->remove('password', 'require')
|
||||
->remove('salt', 'require')
|
||||
->remove('repassword', 'requireWith:password|confirm:password');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user