Login to the same account with google/facebook passport strategies

I currently have Google and Facebook login in my node.js app using Passport.js strategies. but each of them creates separate account because the current queries say: let user = await User.findOne({ facebookId: profile.id }); or let user = await User.findOne({ googleId: profile.id });
I’m trying to make it log to the same account – so i guess the only option to do it is based on the email address like so: let user = await User.findOne({ email: profile.emails[0]}.value );.

Is that sounds like a correct way? Is it safe? Any better ways?


Source: JavaSript – Stack Overflow

September 3, 2021
Category : News
Tags: javascript | node.js | oauth-2.0 | passport.js

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.