评论安全验证
This commit is contained in:
@@ -4,6 +4,7 @@ namespace app\common\service;
|
||||
|
||||
use app\common\model\MessageNotice;
|
||||
use app\common\model\Post;
|
||||
use app\common\model\User;
|
||||
use app\common\validate\PostCommentValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\PostComment;
|
||||
@@ -114,6 +115,20 @@ class PostCommentService
|
||||
}
|
||||
}
|
||||
|
||||
//安全检查
|
||||
$wechat = new WechatService();
|
||||
$tokenData = $wechat->getMiniAccessToken();
|
||||
$access_token = $tokenData['access_token'];
|
||||
|
||||
$user = User::where('id', $request->user->uid)->first();
|
||||
|
||||
if(empty($user)){
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
|
||||
$tokenData = $wechat->checkText($data['content'], $user['openid'], $access_token, 2);
|
||||
// $tokenData = $wechat->checkText($data['content'], 'o8W4t5cRtq2LuOJUxvBGWQA6HJKQ', $access_token, 2);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user