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