瀏覽代碼

请求用户分群,参数timestamp 要是指限时过期60s

liuzejian 1 年之前
父節點
當前提交
40b111a957
共有 2 個文件被更改,包括 4 次插入0 次删除
  1. 3 0
      modules/Audience/Http/Controllers/UserGroupController.php
  2. 1 0
      modules/Common/Errors/Errors.php

+ 3 - 0
modules/Audience/Http/Controllers/UserGroupController.php

@@ -142,6 +142,9 @@ class UserGroupController extends CatchController
             )) {
             CommonBusinessException::throwError(Errors::OPENPLATFORM_UG_SIGN_ERROR);
         }
+        if(time() - 60 > $request->integer('timestamp')) {
+            CommonBusinessException::throwError(Errors::OPENPLATFORM_UG_SIGN_TIMESTAMP_ERROR);
+        }
 
         $tags = DB::table('user_groups')
             ->where([

+ 1 - 0
modules/Common/Errors/Errors.php

@@ -44,4 +44,5 @@ class Errors
     public const OPENPLATFORM_UG_SIGN_ERROR = [500604, '请求用户分群签名错误'];
     public const OPENPLATFORM_UG_NOT_EXISTS = [500605, '用户分群不存在'];
     public const OPENPLATFORM_GZH_SHOUQUAN_ERROR = [500606, '公众号没有授权'];
+    public const OPENPLATFORM_UG_SIGN_TIMESTAMP_ERROR = [500607, '请求用户分群时间戳过期'];
 }