diff --git a/content/database/db.sqlite b/content/database/db.sqlite index c01e16e..9b81657 100644 Binary files a/content/database/db.sqlite and b/content/database/db.sqlite differ diff --git a/src/common/response/notcaptured.filter.ts b/src/common/response/notcaptured.filter.ts index 90d9041..05a1a98 100644 --- a/src/common/response/notcaptured.filter.ts +++ b/src/common/response/notcaptured.filter.ts @@ -27,6 +27,26 @@ export class AllExecptionFilter implements ExceptionFilter { ); } + // 令牌过期 + if(exception.name === 'TokenExpiredError') { + return response.status(HttpStatus.UNAUTHORIZED).json( + Response.create({ + code: ResponseCode.TOKEN_EXPIRED, + message: '登陆已过期' + }) + ) + } + + // 令牌错误 + if(exception.name === 'JsonWebTokenError') { + return response.status(HttpStatus.UNAUTHORIZED).json( + Response.create({ + code: ResponseCode.TOKEN_ERORR, + message: '登陆令牌错误' + }) + ) + } + // 其他异常 response.status(HttpStatus.INTERNAL_SERVER_ERROR).json( Response.create({ diff --git a/src/common/response/response.code.ts b/src/common/response/response.code.ts index 0fbc4c8..63e8002 100644 --- a/src/common/response/response.code.ts +++ b/src/common/response/response.code.ts @@ -10,6 +10,14 @@ export enum ResponseCode { * 客户端未知错误 */ ERROR = 4000, + /** + * 令牌错误 + */ + TOKEN_ERORR = 4050, + /** + * 登陆过期 + */ + TOKEN_EXPIRED = 4051, /** * 参数错误 */