From 16be37640c2641fdfddccbcff1c66a4bb914e625 Mon Sep 17 00:00:00 2001 From: wanghongjun <1445693971@qq,com> Date: Fri, 15 Sep 2023 17:18:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/AgentTeam.php | 29 +++++++++++++++++++++++++++++ app/validate/Agent.php | 2 ++ 2 files changed, 31 insertions(+) diff --git a/app/controller/AgentTeam.php b/app/controller/AgentTeam.php index 6c1de09..f88befc 100644 --- a/app/controller/AgentTeam.php +++ b/app/controller/AgentTeam.php @@ -242,6 +242,35 @@ class AgentTeam extends BaseController ]); } + /** + * 找回密码 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function modifyPassword() + { + $data = Request::param(); + + try { + // 验证代理输入 + validate(Agent::class)->scene('modifyPassword')->check($data); + + $userModel = new AgentUser(); + + $user = $userModel->retrieve(['password' => $data['password'],'aid' => $this->request->userInfo['id']]); + + if ($user['status']) { + return $this->renderSuccess('修改成功'); + } else { + return $this->renderError($user['msg']); + } + } catch (ValidateException $exception) { + return $this->renderError($exception->getMessage()); + } + } + /** * 上分记录 * @return array diff --git a/app/validate/Agent.php b/app/validate/Agent.php index 8e8c2c3..4c51676 100644 --- a/app/validate/Agent.php +++ b/app/validate/Agent.php @@ -17,6 +17,7 @@ class Agent extends Validate 'user_id|用户id' => 'require|number', 'quota|额度' => 'require|number|egt:1', 'password|密码' => 'require|min:6|max:20', + 'repassword|确认密码' => 'require|confirm:password', 'aid|代理id' => 'require|number', 'phone|手机号' => 'require|mobile', ]; @@ -34,5 +35,6 @@ class Agent extends Validate 'edit' => ['aid','password'], 'del' => ['aid'], 'register' => ['phone','password'], + 'modifyPassword' => ['password','repassword'], ]; }