mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-10 04:22:00 +10:00
fix: don't throw error while parsing auth tokens
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
BadRequestException,
|
BadRequestException,
|
||||||
Injectable,
|
Injectable,
|
||||||
|
Logger,
|
||||||
UnauthorizedException,
|
UnauthorizedException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { PassportStrategy } from '@nestjs/passport';
|
import { PassportStrategy } from '@nestjs/passport';
|
||||||
@ -13,6 +14,8 @@ import { FastifyRequest } from 'fastify';
|
|||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
||||||
|
private logger = new Logger('JwtStrategy');
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userRepo: UserRepo,
|
private userRepo: UserRepo,
|
||||||
private workspaceRepo: WorkspaceRepo,
|
private workspaceRepo: WorkspaceRepo,
|
||||||
@ -25,7 +28,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
|
|||||||
try {
|
try {
|
||||||
accessToken = JSON.parse(req.cookies?.authTokens)?.accessToken;
|
accessToken = JSON.parse(req.cookies?.authTokens)?.accessToken;
|
||||||
} catch {
|
} catch {
|
||||||
throw new BadRequestException('Failed to parse access token');
|
this.logger.debug('Failed to parse access token');
|
||||||
}
|
}
|
||||||
|
|
||||||
return accessToken || this.extractTokenFromHeader(req);
|
return accessToken || this.extractTokenFromHeader(req);
|
||||||
|
|||||||
Reference in New Issue
Block a user