From b2147bd28405f29b109f4c6d16de21d5fe55ebe0 Mon Sep 17 00:00:00 2001 From: HarukaKishida Date: Fri, 7 Feb 2025 04:16:27 +0900 Subject: [PATCH] fix the source review ( api-key.strategy.ts ) --- apps/api/src/app/auth/api-key.strategy.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/api/src/app/auth/api-key.strategy.ts b/apps/api/src/app/auth/api-key.strategy.ts index 2914f06c5..e1e067ab7 100644 --- a/apps/api/src/app/auth/api-key.strategy.ts +++ b/apps/api/src/app/auth/api-key.strategy.ts @@ -24,12 +24,13 @@ export class ApiKeyStrategy extends PassportStrategy( super({ header: HEADER_KEY_TOKEN, prefix: 'Api-Key ' }, true); } - public validate = async ( + public async validate( apiKey: string, done: (error: any, user?: any) => void - ) => { + ) { try { const user = await this.validateApiKey(apiKey); + if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { if (hasRole(user, 'INACTIVE')) { throw new HttpException( @@ -52,7 +53,7 @@ export class ApiKeyStrategy extends PassportStrategy( } catch (error) { done(error, null); } - }; + } private async validateApiKey(apiKey: string) { if (!apiKey) {