passport.use(new GoogleStrategy({ clientID: keys.googleClientID, clientSecret: keys.googleClientSecret, callbackURL: '/auth/google/callback', }, async (accessToken, refreshToken, profile, done) => { let user = await User.findOne({google_id: profile.id}); if (!user) { user = await new User({google_id: profile.id}).save(); } done(null, user); }));
passport.use( new GoogleStrategy( { clientID: keys.googleClientID, clientSecret: keys.googleClientSecret, callbackURL: "/auth/google/callback", proxy: true }, (accessToken, refreshToken, profile, done) => { User.findOne({ googleId: profile.id }).then(existingUser => { if (existingUser) { done(null, existingUser); } else { new User({ googleId: profile.id }) .save() .then(user => done(null, user)); } }); } ) );
}, async (accessToken, refreshToken, profile, done) => { const existingUser = await User.findOne({ providerUniqueID: profile.id, provider: profile.provider }) if (existingUser) { existingUser.providerUniqueID = profile.id; existingUser.profileImageURL= profile._json.picture; existingUser.emailVerified= profile._json.email_verified; providerUniqueID: profile.id, provider: profile.provider, accessToken,
passport.use( new GoogleStrategy( { clientID: keys.googleClientID, clientSecret: keys.googleClientSecret, callbackURL: '/auth/google/callback' }, (accessToken, refreshToken, profile, done) => { User.findOne({ googleId: profile.id }).then((existUser) => { if (existUser) { done(null, existUser) } else { new User({ googleId: profile.id }) .save() .then((user) => done(null, user)) } }) } ) )