jaredhanson/passport-local

How to use local strategy on multiple Models?

harishankards opened this issue · 3 comments

Hi,

In my project, I'm having different models say Contractor, Purchaser and Seller. I want to authenticate them. How to configure the passport js for local strategy.

If possible, please let me know the facebook and linkedin auth also.

Hey Dude! I've met the same problem recently!
To solve it, you can just instantiate two local strategies.
Something different is that you need to change the name of the instantiated strategy before you add it to the passport use middleware. Meanwhile, when you use the strategy with passport.authenticate function, the name you input is no longer the default 'local' but the name you set above!!!

Hey @xiangZgnaix ,

Thanks for the help. I fixed it myself in the same way mentioned above long back. Thank you!

Hi @xiangZgnaix and @harishankards I have implemented two local strategies but in my case
even if an admin authenticates, it gets written to req.user and when a user authenticates, it gets written to req.user.I want to get req.user and req.admin, but every time it gets written to req.user,

Can any of you help me with this, please?

Thanks