From 56c288324b00820ea745c8262d731871e013a0c6 Mon Sep 17 00:00:00 2001 From: COOL Date: Sat, 15 Apr 2023 18:27:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=B1=BB=E5=9E=8B=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/package.json | 2 +- packages/core/src/interface.ts | 2 +- packages/core/src/package.json | 2 +- src/modules/base/middleware/authority.ts | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 71e32f8..9a6dc8f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "6.0.2", + "version": "6.0.3", "description": "", "main": "dist/index.js", "typings": "index.d.ts", diff --git a/packages/core/src/interface.ts b/packages/core/src/interface.ts index 870b2f8..9a69f88 100644 --- a/packages/core/src/interface.ts +++ b/packages/core/src/interface.ts @@ -63,7 +63,7 @@ export interface CoolConfig { qiniu?: QINIUConfig; }; /** IOT 配置 */ - iot: CoolIotConfig; + iot?: CoolIotConfig; } export interface CoolRpcConfig { diff --git a/packages/core/src/package.json b/packages/core/src/package.json index 40d7b6b..147e832 100644 --- a/packages/core/src/package.json +++ b/packages/core/src/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "6.0.2", + "version": "6.0.3", "description": "", "main": "index.js", "typings": "index.d.ts", diff --git a/src/modules/base/middleware/authority.ts b/src/modules/base/middleware/authority.ts index 587d7be..a3f673c 100644 --- a/src/modules/base/middleware/authority.ts +++ b/src/modules/base/middleware/authority.ts @@ -1,6 +1,6 @@ import { App, Config, Inject, Middleware } from '@midwayjs/decorator'; import * as _ from 'lodash'; -import { RESCODE } from '@cool-midway/core'; +import { CoolCommException, RESCODE } from '@cool-midway/core'; import * as jwt from 'jsonwebtoken'; import { NextFunction, Context } from '@midwayjs/koa'; import { IMiddleware, IMidwayApplication } from '@midwayjs/core'; @@ -38,7 +38,10 @@ export class BaseAuthorityMiddleware if (_.startsWith(url, adminUrl)) { try { ctx.admin = jwt.verify(token, this.jwtConfig.jwt.secret); - } catch (err) {} + } catch (err) { + throw new CoolCommException('登录失效~'); + } + if (ctx.admin.isRefresh) throw new CoolCommException('登录失效~'); // 不需要登录 无需权限校验 if ( new RegExp(`^${adminUrl}?.*/open/`).test(url) ||