diff --git a/app/BaseApp/BaseService.php b/app/BaseApp/BaseService.php index 6c68d5d8..9ab31b48 100755 --- a/app/BaseApp/BaseService.php +++ b/app/BaseApp/BaseService.php @@ -89,12 +89,18 @@ class BaseService * @var string 时间字段 */ protected string $timeField = 'created_at'; + /** + * @var bool 是否鉴权 + */ + private $auth = true; public function __construct() { - $this->userInfo = JWTService::getInstance()->getToken()->getUserInfo(); - $this->userId = $this->userInfo['id'] ?? 0; - $this->roleId = $this->userInfo['role_id'] ?? 0; + if ($this->auth === true) { + $this->userInfo = JWTService::getInstance()->getToken()->getUserInfo(); + $this->userId = $this->userInfo['id'] ?? 0; + $this->roleId = $this->userInfo['role_id'] ?? 0; + } $this->utils = UtilsService::getInstance(); }