Thanks for taking a look. This is the syntax error I am getting:
[0] /Users/alexkarasik/Documents/server/services/passport.js:26
[0] async (accessToken, refreshToken, profile, done) => {
[0] ^
[0] SyntaxError: Unexpected token (
and this is the file that error is referencing. I've been looking thing up and down now for over 2 hours and see no reason to be getting this error:
const passport = require('passport');
const GoogleStrategy = require('passport-google-oauth20').Strategy;
const mongoose = require('mongoose');
const keys = require('../config/keys');
const User = mongoose.model('users');
passport.serializeUser((user, done) => {
done(null, user.id);
});
passport.deserializeUser((id, done) => {
User.findById(id)
.then(user => {
done(null, user);
})
});
passport.use(
new GoogleStrategy({
clientID: keys.googleClientID,
clientSecret: keys.googleClientSecret,
callbackURL: '/auth/google/callback',
proxy: true
},
async (accessToken, refreshToken, profile, done) => {
const existingUser = await User.findOne({ googleId: profile.id });
if (existingUser){
//we already have a record with the give profileId
return done(null, existingUser);
}
// we don't have a user record with this ID, make a new record
const user = await new User({ googleId: profile.id }).save();
done(null, user);
}
)
);
I really appreciate any input.
Node was just not updated properly for the newer ES6 syntax. Updating it solved this issue. Thank you for your help.