this is my passport.js file
const GoogleStratergy = require('passport-google-oauth20').Strategy
const mongoose = require('mongoose')
const User = require('../../models/User')
module.exports = function(passport){
passport.use(new GoogleStratergy({
clientID:process.env.GOOGLE_CLIENT_ID,
clientSecret:process.env.GOOGLE_CLIENT_SECRET,
callbackURL:'/auth/google/callback'
},async (accessToken,refreshToken,profile,done)=>{
const newUser = {
googleId:profile.id,
displayName:profile.displayName,
firstName:profile.name.givenName,
lastName:profile.name.familyName,
image:profile.photos[0].value
}
try{
let user = await User.findOne({googleId:profile.id})
if(user){
done(null,user)
}
else{
user = await User.create(newUser)
done(null,user)
}
}
catch{
console.log(err)
}
}))
passport.serializeUser((user, done)=>{
done(null, user.id);
});
passport.deserializeUser((id, done)=>{
User.findById(id,(err, user)=>{
done(err, user);
});
});
}
it has no issues its working properly but I want to use with react how can I do that
tutorials that I watched
these dont have what I require cuz I want to sign in using react fornt end and then save that data using mongoose in node