i'm new to nestjs, i've already set a "jwt" PassportStrategy with his relative AuthGuard, now i have to create a complete different "jwt" PassportStrategy and his relative AuthGuard, how can i do this? Do you have any examples?
2
votes
1 Answers
2
votes
Firstly you create another strategy class. The second argument when extending the base PassportStrategy will be the name of your strategy which you can use with AuthGuard to specify which strategy it will use.
export class OtherStrategy extends PassportStrategy(Strategy, 'other-strategy')
{ STRATEGY IMPLEMENTATION }
Then you can use it in your controller like
@UseGuards(AuthGuard('other-strategy')
@Post('/my-endpoint')