<commit_before>var passport = require("passport");
var GoogleAuth = require("passport-google-oauth20").Strategy;
var config = require("../config");
var mongoose=require('mongoose')

const User = mongoose.model('users')

//define gogole strategy with passport
passport.use(
    new GoogleAuth(
      {
        clientID: config.clientID,
        clientSecret: config.clientSecret,
        callbackURL: "/auth/google/callback"
      },
      function(accessToken,refreshToken,profile,done) { //callback after getting authenticated by google
       new User({
        googleID:profile.id
       }).save();
      }
    )
  );<commit_msg>checking foe existing user and finishing the callback<commit_after>var passport = require("passport");
var GoogleAuth = require("passport-google-oauth20").Strategy;
var config = require("../config");
var mongoose=require('mongoose')

const User = mongoose.model('users')

//define gogole strategy with passport
passport.use(
    new GoogleAuth(
      {
        clientID: config.clientID,
        clientSecret: config.clientSecret,
        callbackURL: "/auth/google/callback"
      },
      function(accessToken,refreshToken,profile,done) { //callback after getting authenticated by google
        User.findOne({googleID:profile.id}).then(function(existingUser){
          if(existingUser){
            done(null,existingUser)
          }
          else{
            new User({googleID:profile.id}).save().then(user => done(null,user));
          }
        }) 
      }
    )
  );
{'fraction_non_alphanumeric': 0.12640635340833886, 'fraction_numerical': 0.0026472534745201853, 'mean_word_length': 3.021276595744681, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1264664', 'n_tokens_mistral': 425, 'n_tokens_neox': 419, 'n_words': 88}