nestjs/jwt

Unknown authentication strategy "jwt"

Flusinerd opened this issue · 1 comments

I'm submitting a...


[ ] Regression 
[ X ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

In error
Unknown authentication strategy "jwt"

Expected behavior

jwt beeing an known authentication strategy

Minimal reproduction of the problem with instructions

authModule:

@Module({
  providers: [
    AuthenticationService,
    JwtStrategy
  ],
  imports: [
    JwtModule.register({
      secret: jwtConstants.secret,
      signOptions: { expiresIn: "1d" },
    }),
    UsersModule,
  ],
  exports: [AuthenticationService, JwtModule]
})
export class AuthenticationModule {}

User Module

@Module({
  imports: [TypeOrmModule.forFeature([User])],
  providers: [UsersService],
  controllers: [UsersController],
  exports: [UsersService]
})
export class UsersModule {}

users controller

@UseGuards(JwtAuthGuard)
  @Get()
  async getAll(){
    return this.usersService.findAll();
  }

JwtAuthGuard

@Injectable()
export class JwtAuthGuard extends AuthGuard('jwt') {}

What is the motivation / use case for changing the behavior?

Making use of the jwt authentication guard

Environment


Nest version: 6.11.8

 
For Tooling issues:
- Node version: 10.15.1
- Platform:  Windows

Others:
Followed along the docs. Made sure that the Strategy is in the providers.
Doesnt work in app.controller.ts either

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.