Another (hopefully simple) passport question (passport.authenticate())
I'm following a great passport guide by a guy called zach gollwitzer - would really recommend: https://www.youtube.com/watch?v=F-sFp_AvHc8
He talks about using the
as middleware in my route:
So
route.post('/login', passport.authenticate(...), controller.login())
He says that I don't need controller.login()
because authenticate
provides success and failure redirects. But I'm using a REST backend, so I'm not redirecting anywhere. The passport docs say that the function will produce an HTTP 401 Unauthorized response... and the request-response cycle will end.
when authentication fails.
So I'm guessing I can just deal with the successful logic in controller.login()
, and that authenticate
will just call next if successful?freeCodeCamp.org
YouTube
User Authentication in Web Apps (Passport.js, Node, Express)
In this full course for beginners, you will learn how to implement user authentication from scratch in your web apps. You will learn how to use Passport.js in a Node / Express app.
š» Starter Code
š https://github.com/zachgoll/express-session-authentication-starter
š https://github.com/zachgoll/express-jwt-authentication-starter
āļø Course creat...
1 Reply
I've done 2 projects using passport.js and this is the first time seeing the
controller.login()
middleware. My apps work fine without it, so I don't think it is needed.