backstage seeds upload

This commit is contained in:
yanwenwu
2018-11-21 11:10:25 +08:00
parent 0e0492978c
commit a38ec53d1d
8 changed files with 313 additions and 3 deletions

View File

@@ -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('修改失败');
}

View File

@@ -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);
}
}