fix(presence-service): JWT guard 向后兼容无 type 字段的旧 token

新 token 含 type:'access',旧 token 无 type 字段。
改为:只有 type 字段存在且不为 'access' 时才拒绝,
避免已登录用户因旧 token 格式导致心跳永久 401。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-05 21:16:01 -08:00
parent 330f8c7681
commit a01355aecc
1 changed files with 2 additions and 1 deletions

View File

@ -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 字段)和新 tokentype: 'access'
if (payload.type && payload.type !== 'access') throw new UnauthorizedException('无效的令牌类型');
request.user = {
userId: payload.userId,
accountSequence: payload.accountSequence,