Ver código fonte

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

liuzejian 1 ano atrás
pai
commit
40b111a957

+ 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, '请求用户分群时间戳过期'];
 }