diff --git a/apps/api/src/app/auth/api-key.strategy.ts b/apps/api/src/app/auth/api-key.strategy.ts index 232a272bc..b94c04148 100644 --- a/apps/api/src/app/auth/api-key.strategy.ts +++ b/apps/api/src/app/auth/api-key.strategy.ts @@ -66,7 +66,16 @@ export class ApiKeyStrategy extends PassportStrategy( try { const { id } = await this.apiKeyService.getUserByApiKey(apiKey); - return this.userService.user({ id }); + const user = await this.userService.user({ id }); + + if (!user) { + throw new HttpException( + getReasonPhrase(StatusCodes.UNAUTHORIZED), + StatusCodes.UNAUTHORIZED + ); + } + + return user; } catch { throw new HttpException( getReasonPhrase(StatusCodes.UNAUTHORIZED),