Skip to content

How do I incorporate passport js for authentication? #921

Answered by RobinTail
egithinji asked this question in Q&A
Discussion options

You must be logged in to vote

@egithinji ,

Passport is a great library with a perfect abstraction levels. It's a good choice.

This is the actual function that .authenticate() creates:

https://github.com/jaredhanson/passport/blob/master/lib/middleware/authenticate.js#L70

They call it "middleware", however, it acts more like an endpoint handler, because in general scenario it does not call next().
Instead, it calls response.end():

https://github.com/jaredhanson/passport/blob/master/lib/middleware/authenticate.js#L333

Since next() is not called, your handler is never called as well.

Long story short: Passport takes the complete control over authentication routes, it's a not something that expected to be ran in between. T…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@egithinji
Comment options

Comment options

You must be logged in to vote
1 reply
@RobinTail
Comment options

Answer selected by RobinTail
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants