nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.44k stars 7.6k forks source link

Unknown authentication strategy "local" #3559

Closed rumsky closed 4 years ago

rumsky commented 4 years ago

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            
unckleg commented 4 years ago

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

tananai commented 4 years ago

I am in the same situation of @rumsky

samanshahmohamadi commented 4 years ago

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.

munkk commented 4 years ago

same here any updates?

munkk commented 4 years ago

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

rumsky commented 4 years ago

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 {}
PierreTurnbull commented 4 years ago

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

PierreTurnbull commented 4 years ago

@cjancsar why downvoting my comment though?