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:
parent
330f8c7681
commit
a01355aecc
|
|
@ -23,7 +23,8 @@ export class JwtAuthGuard implements CanActivate {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const payload = await this.jwtService.verifyAsync(token);
|
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 = {
|
request.user = {
|
||||||
userId: payload.userId,
|
userId: payload.userId,
|
||||||
accountSequence: payload.accountSequence,
|
accountSequence: payload.accountSequence,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue