Giter Club home page Giter Club logo

Comments (9)

rvieceli avatar rvieceli commented on June 18, 2024 1

@jmcdo29 I looked at lib/auth.guard and I saw this In order to use "defaultStrategy", please, ensure to import PassportModule in each place where AuthGuard() is being used. Otherwise, passport won't work correctly..

Then, I added PassportModule.register({}) (only PassportModule don't work) in all the modules that use @UseGuards(JwtAuthenticationGuard) and it works with 8.1.1

from passport.

jmcdo29 avatar jmcdo29 commented on June 18, 2024 1

Only if

  1. you have a PassportModule.register() with options you want to have used (like user property )
  2. You have a guard that needs to AuthService

Otherwise, it shouldn't really be necessary, but it is at the moment because of the change

from passport.

jmcdo29 avatar jmcdo29 commented on June 18, 2024 1

@cleytoncoro if you'd read the above comments in the issue, and the linked PR, you'd realize this already has a fix, and there's solutions in the thread already. Kamil will most likely publish a patch or minor update for this once the PR is merged.

from passport.

jmcdo29 avatar jmcdo29 commented on June 18, 2024

For a quick workaround, use PassportModule.register({}) instead of just PassportModule. I'll have a fix up for this later.

Thanks for reporting it it. I'll make sure the test suite gets updated with a case to cover this

from passport.

rvieceli avatar rvieceli commented on June 18, 2024

@jmcdo29 I tried, but it still doesn't work. I went back to 8.1.0. I'm just learning. Thanks.

from passport.

jmcdo29 avatar jmcdo29 commented on June 18, 2024

Okay, yeah, that tracks. I was using a single module setup for testing this. You would need to use the PassportModule.register({}) and then have your AuthModule have PassportModule in the exports and ensure that AuthModule was imported wherever you use the AuthGuard().

Turns out, I needed to add @Optional() to the property injector as well, so the fix is easy, it's just making sure our test suite is updated now

from passport.

rvieceli avatar rvieceli commented on June 18, 2024

@jmcdo29 in a normal situation (without this issue), should I always import AuthModule in all modules I use UseGuards?

from passport.

cleytoncoro avatar cleytoncoro commented on June 18, 2024

Following nest docs (https://docs.nestjs.com/security/authentication) i found this error too after implementing local strategy (after "Implementing Passport local" topic and before "Built-in Passport Guards").

Downgrading to 8.1.0 all things works fine.

I'm start learning nestjs and I don't now how to colaborate sending PR. Maybe this repo needs an update, or maybe nestjs docs needs to be updated.

image

from passport.

kamilmysliwiec avatar kamilmysliwiec commented on June 18, 2024

Fixed

from passport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.