diff --git a/backend/services/presence-service/src/shared/guards/jwt-auth.guard.ts b/backend/services/presence-service/src/shared/guards/jwt-auth.guard.ts index 761cdfb7..8d4b0a2e 100644 --- a/backend/services/presence-service/src/shared/guards/jwt-auth.guard.ts +++ b/backend/services/presence-service/src/shared/guards/jwt-auth.guard.ts @@ -23,7 +23,8 @@ export class JwtAuthGuard implements CanActivate { try { const payload = await this.jwtService.verifyAsync(token); - if (payload.type !== 'access') throw new UnauthorizedException('无效的令牌类型'); + // 兼容旧 token(无 type 字段)和新 token(type: 'access') + if (payload.type && payload.type !== 'access') throw new UnauthorizedException('无效的令牌类型'); request.user = { userId: payload.userId, accountSequence: payload.accountSequence,