Browse Source

fix apikeystrategy bug

pull/4682/head
Andrei D 4 months ago
parent
commit
36178d6617
  1. 11
      apps/api/src/app/auth/api-key.strategy.ts

11
apps/api/src/app/auth/api-key.strategy.ts

@ -21,13 +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
) {
public async validate(apiKey: string): Promise<any> {
try {
const user = await this.validateApiKey(apiKey);
@ -49,9 +46,9 @@ export class ApiKeyStrategy extends PassportStrategy(
});
}
done(null, user);
return user;
} catch (error) {
done(error, null);
throw error;
}
}

Loading…
Cancel
Save