backstage seeds upload
This commit is contained in:
@@ -36,7 +36,7 @@ class User extends Base
|
||||
if ($err = $validate->getErrors($data)) {
|
||||
$this->error($err);
|
||||
}
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
$data['password'] = generatePassword($data['password']);
|
||||
if ($userId = $userModel->store($data)) {
|
||||
// 分配角色
|
||||
$this->giveRoles($userModel, $userId, $data);
|
||||
@@ -63,7 +63,7 @@ class User extends Base
|
||||
$this->error($err);
|
||||
}
|
||||
$this->giveRoles($userModel, $data['id'], $data);
|
||||
$data['password'] = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
$data['password'] = generatePassword($data['password']);
|
||||
$userModel->updateBy($data['id'], $data) ? $this->success('修改成功', url('user/index')) : $this->error('修改失败');
|
||||
}
|
||||
|
||||
|
@@ -56,3 +56,12 @@ if (!function_exists('searchButton')) {
|
||||
return sprintf('<button class="btn btn-white" type="submit"><i class="fa fa-search"></i> %s</button>', $name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成密码
|
||||
*/
|
||||
if (!function_exists('generatePassword')) {
|
||||
function generatePassword(string $password, int $algo = PASSWORD_DEFAULT) {
|
||||
return password_hash($password, $algo);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user