I have a node.js application which uses passport (with a modified passport-local for the login strategy) for authentication management. I would like to allow users to connect their social network accounts using passport strategies, but from what I can see the existing authentication (on the request object) gets overwritten when a new one is made.
How should I approach this?
Passport is a popular, modular authentication middleware for Node. js applications. With it, authentication can be easily integrated into any Node- and Express-based app. The Passport library provides more than 500 authentication mechanisms, including OAuth, JWT, and simple username and password based authentication.
I was using passport.authenticate when I should have been using passport.authorize!
docs here: http://passportjs.org/guide/authorize/
I've created a sample for that see https://github.com/fpp/drywall
It allows to associate one or more social accounts with a local strategy user, create local strategy users from social accounts, plus add/remove social accounts from these users.
Currently twitter & github are implemented - just add other passport versions and adjust the code sample for more services.
The sample uses Node.js 0.8x, express 3.x and backbone.js - includes some basic user management from the http://jedireza.github.com/drywall/ sample project.
P.S. I could not get a second route (for the same social service) / authorize vs authenticate with passport working as described in the passport documentation. Use
passReqToCallback: true
in the strategy instead and work on the user (see example for more).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With