Nest: Unknown authentication strategy "local"

Created on 6 Dec 2019  路  8Comments  路  Source: nestjs/nest

Bug Report

Current behavior

follow the docs https://docs.nestjs.com/techniques/authentication. This is a error :"Error: Unknown authentication strategy "local""

Environment


Nest version:6.7.2
"passport": "^0.4.0",
"passport-local": "^1.0.0",

For Tooling issues:

  • Node version: v12.13.0
  • Platform: Mac
needs triage

Most helpful comment

I am in the same situation of @rumsky

All 8 comments

Any news on this one ? Any service dependent on Request scope will break the passport.

I am in the same situation of @rumsky

I encountered same issue in a project which I created from scratch. But sample _19-auth-jwt_ in this repository is working just fine. I could not find the difference between this sample and my project.

same here
any updates?

i repeated all steps in that nest.js guide and somehow it started work :) seems that i forgot to add a module or so...

Sorry, I encountered this problem because I miss provide 'LocalStrategy' in auth.module.ts.
Please check your providers and imports

auth/auth.module.ts
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { UsersModule } from '../users/users.module';
import { PassportModule } from '@nestjs/passport';
import { LocalStrategy } from './local.strategy';

@Module({
  imports: [UsersModule, PassportModule],
  providers: [AuthService, LocalStrategy],
})
export class AuthModule {}

I faced the same problem, and the solution was to add the AuthModule in the imports of my app module (app.module.ts).

@cjancsar why downvoting my comment though?

Was this page helpful?
0 / 5 - 0 ratings