Browse Source
Bugfix/fix ApiKeyStrategy error (#4682)
* Fix ApiKeyStrategy error
pull/4678/head
andiz2
2 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
19 additions and
26 deletions
-
apps/api/src/app/auth/api-key.strategy.ts
|
|
@ -21,14 +21,10 @@ export class ApiKeyStrategy extends PassportStrategy( |
|
|
|
private readonly prismaService: PrismaService, |
|
|
|
private readonly userService: UserService |
|
|
|
) { |
|
|
|
super({ header: HEADER_KEY_TOKEN, prefix: 'Api-Key ' }, true); |
|
|
|
super({ header: HEADER_KEY_TOKEN, prefix: 'Api-Key ' }, false); |
|
|
|
} |
|
|
|
|
|
|
|
public async validate( |
|
|
|
apiKey: string, |
|
|
|
done: (error: any, user?: any) => void |
|
|
|
) { |
|
|
|
try { |
|
|
|
public async validate(apiKey: string) { |
|
|
|
const user = await this.validateApiKey(apiKey); |
|
|
|
|
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { |
|
|
@ -49,10 +45,7 @@ export class ApiKeyStrategy extends PassportStrategy( |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
done(null, user); |
|
|
|
} catch (error) { |
|
|
|
done(error, null); |
|
|
|
} |
|
|
|
return user; |
|
|
|
} |
|
|
|
|
|
|
|
private async validateApiKey(apiKey: string) { |
|
|
|