소스 검색

【程序目录】token优化

evoxwht 3 년 전
부모
커밋
8e55004d3f
1개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 6 1
      crmeb/crmeb/utils/JwtAuth.php

+ 6 - 1
crmeb/crmeb/utils/JwtAuth.php

@@ -95,7 +95,12 @@ class JwtAuth
     {
         $tokenInfo = $this->getToken($id, $type, $params);
         $exp = $tokenInfo['params']['exp'] - $tokenInfo['params']['iat'] + 60;
-        $res = CacheService::setTokenBucket(md5($tokenInfo['token']), ['uid' => $id, 'type' => $type, 'token' => $tokenInfo['token'], 'exp' => $exp], (int)$exp);
+        if (in_array($type, ['api', 'wechat', 'routine'])) {
+            $type = 'api' . $id;
+        } else {
+            $type = 'admin';
+        }
+        $res = CacheService::setTokenBucket(md5($tokenInfo['token']), ['uid' => $id, 'type' => $type, 'token' => $tokenInfo['token'], 'exp' => $exp], (int)$exp, $type);
         if (!$res) {
             throw new AdminException(ApiErrorCode::ERR_SAVE_TOKEN);
         }