From 42315c0f7db864c3fc71a1008a30646fff07a744 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 26 Dec 2025 15:51:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=86=85=E5=AE=B9=E9=A3=8E?= =?UTF-8?q?=E9=99=A9=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/PostController.php | 2 +- app/common/service/PostService.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/common/controller/PostController.php b/app/common/controller/PostController.php index 663d614..250f567 100644 --- a/app/common/controller/PostController.php +++ b/app/common/controller/PostController.php @@ -41,7 +41,7 @@ class PostController extends BaseController $res = $this->service->serviceStore($request, $data); return $this->success($res, '创建成功'); } catch (\Throwable $e) { - return $this->error($e->getMessage().$e->getLine().$e->getFile()); + return $this->error($e->getMessage()); } } diff --git a/app/common/service/PostService.php b/app/common/service/PostService.php index 078021b..d2ea3ea 100644 --- a/app/common/service/PostService.php +++ b/app/common/service/PostService.php @@ -110,6 +110,19 @@ class PostService public function beforeServiceStore($data, Request $request) { $data['user_id'] = $request->user->uid;; + + //安全检查 + $wechat = new WechatService(); + $tokenData = $wechat->getMiniAccessToken(); + $access_token = $tokenData['access_token']; + + $user = User::where('id', $data['user_id'])->first(); + if(empty($user)){ + throw new \Exception('用户不存在'); + } + $tokenData = $wechat->checkText($data['content'], $user['openid'], $access_token, 2); + + $user = User::where('id', $data['user_id'])->first(); if($user->is_release == 0){ $staff = UserStaff::where('name',$user->name)->where('sn',$user->sn)->first();