From 27eab82f19d1cba8109a6bd6851d8febc66a54b8 Mon Sep 17 00:00:00 2001 From: Tom Avalexing Date: Wed, 4 Oct 2023 16:46:41 +0300 Subject: [PATCH] Workaround for bug on token conflict with front and storybook (#1843) * workound to preview token * remote token itself --- server/src/app.module.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/app.module.ts b/server/src/app.module.ts index 32d386d3b..b40f38c87 100644 --- a/server/src/app.module.ts +++ b/server/src/app.module.ts @@ -7,7 +7,7 @@ import { YogaDriver, YogaDriverConfig } from '@graphql-yoga/nestjs'; import GraphQLJSON from 'graphql-type-json'; import { GraphQLError, GraphQLSchema } from 'graphql'; import { ExtractJwt } from 'passport-jwt'; -import { TokenExpiredError, verify } from 'jsonwebtoken'; +import { TokenExpiredError, JsonWebTokenError, verify } from 'jsonwebtoken'; import { AppService } from './app.service'; @@ -77,6 +77,14 @@ import { return conditionalSchema; } catch (error) { + if (error instanceof JsonWebTokenError) { + //mockedUserJWT + throw new GraphQLError('Unauthenticated', { + extensions: { + code: 'UNAUTHENTICATED', + }, + }); + } if (error instanceof TokenExpiredError) { throw new GraphQLError('Unauthenticated', { extensions: {