diff --git a/app/controller/api/UserController.php b/app/controller/api/UserController.php index 20bd640..e49e0bb 100644 --- a/app/controller/api/UserController.php +++ b/app/controller/api/UserController.php @@ -130,4 +130,25 @@ class UserController ]; return ApiResponseApp::success($res); } + + /** + * @Apidoc\Title("1.0 修改密码") + * @Apidoc\Url("api/user/uppassword") + * @Apidoc\Method("POST") + */ + public function uppassword(Request $request) + { + $old_password = $request->post('old_password'); + $new_password = $request->post('new_password'); + $user_id=$request->data['id']; + $user=User::find($user_id); + if (!password_verify($old_password, $user->password)) { + return ApiResponseApp::error([], "原密码错误"); + } + //修改密码 + $user->password = password_hash($new_password, PASSWORD_DEFAULT); + //保存到数据库 + $user->save(); + return ApiResponseApp::success('修改成功'); + } }