Browse Source

fix the source review ( api-key.strategy.ts )

pull/4270/merge^2
HarukaKishida 2 months ago
parent
commit
b2147bd284
  1. 7
      apps/api/src/app/auth/api-key.strategy.ts

7
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); super({ header: HEADER_KEY_TOKEN, prefix: 'Api-Key ' }, true);
} }
public validate = async ( public async validate(
apiKey: string, apiKey: string,
done: (error: any, user?: any) => void done: (error: any, user?: any) => void
) => { ) {
try { try {
const user = await this.validateApiKey(apiKey); const user = await this.validateApiKey(apiKey);
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
if (hasRole(user, 'INACTIVE')) { if (hasRole(user, 'INACTIVE')) {
throw new HttpException( throw new HttpException(
@ -52,7 +53,7 @@ export class ApiKeyStrategy extends PassportStrategy(
} catch (error) { } catch (error) {
done(error, null); done(error, null);
} }
}; }
private async validateApiKey(apiKey: string) { private async validateApiKey(apiKey: string) {
if (!apiKey) { if (!apiKey) {

Loading…
Cancel
Save