fix return value in context
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { Injectable, Logger, UnauthorizedException } from '@nestjs/common';
|
||||
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { Request } from 'express';
|
||||
@@ -11,18 +11,19 @@ export class GraphqlService {
|
||||
async acquireContext(req: Request) {
|
||||
// get x-session-id from headers
|
||||
let sessionId: string;
|
||||
const disableAuth = process.env.DISABLE_AUTH === 'true';
|
||||
try {
|
||||
sessionId = req.headers['x-session-id'] as string;
|
||||
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (error) {
|
||||
if (
|
||||
process.env.NODE_ENV === 'development' &&
|
||||
process.env.DISABLE_AUTH === 'true'
|
||||
) {
|
||||
if (disableAuth) {
|
||||
return null;
|
||||
}
|
||||
throw new UnauthorizedException('Must provide a session ID');
|
||||
}
|
||||
if (disableAuth) {
|
||||
return null;
|
||||
}
|
||||
// check if the token is valid
|
||||
const session = await clerkClient.sessions.getSession(sessionId as string);
|
||||
if (!session) {
|
||||
|
||||
Reference in New Issue
Block a user