fix(presence-service): JWT guard 用 sub 兼容旧 token 的 userId/accountSequence

旧 token 只有 sub 字段,新 token 有 userId/accountSequence。
用 payload.userId ?? payload.sub 兼容两种格式,
确保旧 token 心跳能正确写入在线状态。

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

View File

@ -26,8 +26,8 @@ export class JwtAuthGuard implements CanActivate {
// 兼容旧 token无 type 字段)和新 tokentype: 'access' // 兼容旧 token无 type 字段)和新 tokentype: 'access'
if (payload.type && payload.type !== 'access') throw new UnauthorizedException('无效的令牌类型'); if (payload.type && payload.type !== 'access') throw new UnauthorizedException('无效的令牌类型');
request.user = { request.user = {
userId: payload.userId, userId: payload.userId ?? payload.sub,
accountSequence: payload.accountSequence, accountSequence: payload.accountSequence ?? payload.sub,
deviceId: payload.deviceId, deviceId: payload.deviceId,
}; };
} catch { } catch {