Git Product home page Git Product logo

Comments (4)

Offlein avatar Offlein commented on April 29, 2024 9

I'm confused by the Inheritance section you refer to, @kamilmysliwiec.

In that section, you have a code comment that reads:

// Add your custom authentication logic here
// for example, call super.logIn(request) to establish a session.

But request is not defined in that context. I assume I am meant to get it instead like super.logIn(context.switchToHttp().getRequest());?

As well, there's a sample app for this section (https://github.com/nestjs/nest/tree/master/sample/19-auth/src) which has a jwt-auth.guard.ts file in, but that file isn't even seemingly called from anywhere.

Assuming that the super.logIn method actually works (and it would be great to understand how and why this is happening), I didn't understand for a while how to implement my custom AuthGuard child class.

Finally, I imported it as a provider in the .module.ts file, and then, in my controller, replaced the @UseGuards(AuthGuard('google')) line I had (..using Google, obviously!) with @UseGuards(GoogleAuthGuard), and I think I might be at least moving forward. Although I don't know if that's right or wrong.

...Although I'm getting issues in my Google strategy now, so we'll see what's up there... It's running my Strategy's serializeUser method with an undefined user and then crashing.

Edit: Whoops; I realized it wasn't crashing, just throwing a console.log because serializeUser didn't have a User yet.

Anyway, I successfully got the Google OAuth2 page, clicked it and got a profile back (which I've been able to do since yesterday), but it's still not an active session. When I go back to a page that requires auth, it still has no user in serializeUser and re-prompts me back to Google's authentication. :(

from passport.

artonio avatar artonio commented on April 29, 2024 3

Yes I ran into the same issue, the documentation is quite young but I did manage to get it working, and here is a tutorial on it: NestJS Basic Auth and Sessions Tutorial

from passport.

Kapnobatai3434 avatar Kapnobatai3434 commented on April 29, 2024 1

Hey guys, will this fix be merged into the master branch?

from passport.

kamilmysliwiec avatar kamilmysliwiec commented on April 29, 2024

See Inheritance section https://docs.nestjs.com/techniques/authentication

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.