feat(user): 后台用户管理增加重置密码功能,并将部署流程默认调整为纯代码部署(不同步数据库)

这个提交包含在:
2026-11-23 17:54:01 +08:00
父节点 c2f3fcc368
当前提交 45ed55b644
共有 13 个文件被更改,包括 272 次插入 和 184 次删除

查看文件

@@ -9,16 +9,6 @@ use think\Db;
class Security extends Base
{
private function verifyBoundPhone($code, $mobile)
{
if (trim((string)$code) === '') $this->error('请先验证绑定的微信手机号');
$phone = WxLogin::getPhoneNumber((string)$code);
$verified = isset($phone['purePhoneNumber']) ? (string)$phone['purePhoneNumber'] : (string)($phone['phoneNumber'] ?? '');
if (isset($phone['error']) || $verified === '' || !hash_equals((string)$mobile, $verified)) {
$this->error('手机号验证失败,请使用绑定手机号重新验证');
}
}
public function status()
{
$user = Db::name('user')->field('password,mobile')->where('id', $this->uid())->find();
@@ -37,12 +27,11 @@ class Security extends Base
$new = (string)$this->request->post('new_password', '');
$old = (string)$this->request->post('old_password', '');
if (!preg_match('/^\S{6,30}$/', $new)) $this->error('登录密码须为6至30位非空字符');
$user = Db::name('user')->field('password,mobile')->where('id', $uid)->find();
$user = Db::name('user')->field('password')->where('id', $uid)->find();
if (!empty($user['password'])) {
try { AccountSecurity::verify($uid, 'login', $old); } catch (\Throwable $e) { $this->error($e->getMessage()); }
$ignoreOld = false;
} else {
$this->verifyBoundPhone($this->request->post('phone_code', ''), $user['mobile']);
$ignoreOld = true;
}
if (!$this->auth->changepwd($new, $old, $ignoreOld)) $this->error($this->auth->getError() ?: '设置失败');
@@ -55,8 +44,7 @@ class Security extends Base
$uid = $this->uid();
$new = (string)$this->request->post('new_password', '');
if (!preg_match('/^\d{6}$/', $new)) $this->error('支付密码须为6位数字');
try { AccountSecurity::verify($uid, 'login', (string)$this->request->post('login_password', '')); }
catch (\Throwable $e) { $this->error($e->getMessage()); }
AccountSecurity::ensure($uid);
$updated = Db::name('user_security')->where('user_id', $uid)->where('payment_password_hash', '')->update(['payment_password_hash' => password_hash($new, PASSWORD_DEFAULT)]);
if (!$updated) $this->error('支付密码已设置,请使用修改功能');
$this->success('支付密码设置成功');