I have an anonymous passport strategy defined as:
// In anonymous.strategy.ts
import {Strategy} from 'passport-anonymous'
import {PassportStrategy} from '@nestjs/passport'
import {Injectable} from '@nestjs/common'
@Injectable()
export class AnonymousStrategy extends PassportStrategy(Strategy, 'anonymous') {
constructor() {
super()
}
// Request times out unless this function is enabled
// authenticate() {
// return this.success({})
//}
}
Which I then added to the AuthGuards()
chain in the controller after 'jwt' one:
@UseGuards(AuthGuard(['jwt', 'anonymous']))
@Post('/posts')
createAd(@Req() req: Request, @Body() createPostDto: CreatePostDto) {
...
}
I can't understand why the request times out unless I enable the authenticate()
function in the strategy? After all, I don't have to do this for the passport-jwt
strategy. Am I missing something? Thank you.