<commit_before>var express = require("express"),
	morgan  = require('morgan'),
    path = require('path'), 
    passport = require('passport'), 
    userRoutes = require('./routes/users.js'),
    eventRoutes= require('./routes/events.js'),
    gcal = require('google-calendar'),
    GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;

var User = require("./models/user.js");


var cookieParser = require('cookie-parser'), 
    bodyParser = require('body-parser'),
    session= require('express-session'),
    methodOverride = require('method-override');


var app = express();

function findById(id, fn) {
  console.log("deserialize helper function findById");
  User.findOne("user", {'id': id}, function (err, user) {
    if (err) {
      return fn(err, null);
    } else {
      return fn(null, user);
    }
  });
}

// Passport session setup.
//   To support persistent login sessions, Passport needs to be able to
//   serialize users into and deserialize users out of the session.  Typically,
//   this will be as simple as storing the user ID when serializing, and finding
//   the user by ID when deserializing.  However, since this example does not
//   have a database of user records, the complete Google profile is serialized
//   and deserialized.
passport.serializeUser(function(user, done) {
  //do put 
  console.log("in serialize user is : " + JSON.stringify(user) + " and id is " + user.id);
  done(null, user.id);// primary key 
});

passport.deserializeUser(function(obj, done) { //obj= user.id 
  //find obj 
  findById(obj, function(err, user) {
    done(err, user);
  });
  //done(null, obj);
});


// passport.use(new GoogleStrategy({
//     returnURL: 'http://localhost:50000/auth/google/return',
//     realm: 'http://localhost:50000/'
//   },
//   function(identifier, profile, done) {
//     // asynchronous verification, for effect...
//     process.nextTick(function () {
      
//       // To keep the example simple, the user's Google profile is returned to
//       // represent the logged-in user.  In a typical application, you would want
//       // to associate the Google account with a user record in your database,
//       // and return that user instead.
//       profile.identifier = identifier;
//       return done(null, profile);
//     });
//   }
// ));

passport.use(new GoogleStrategy({
    clientID: '351029077337-lj4ufniaiasdp9gqs36iev730vsuhmsa.apps.googleusercontent.com',
    clientSecret: '<KEY>',
    callbackURL: 'http://localhost:50000/auth/google/return' ///"http://setmeetings-lisajung.rhcloud.com/auth/google/return"
  },
  function(token, tokenSecret, profile, done) {
    // asynchronous verification, for effect...
    profile.accessToken = token;

    process.nextTick(function () {
      console.log("in profile stuff");
      // To keep the example simple, the user's Google profile is returned to
      // represent the logged-in user.  In a typical application, you would want
      // to associate the Google account with a user record in your database,
      // and return that user instead.  
    

      //var newUser = { id: profile.id, displayName: profile.displayName, emails: profile.emails[0].value };
      <commit_msg>aweo;ifjawe<commit_after>var express = require("express"),
	morgan  = require('morgan'),
    path = require('path'), 
    passport = require('passport'), 
    userRoutes = require('./routes/users.js'),
    eventRoutes= require('./routes/events.js'),
    gcal = require('google-calendar'),
    GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;

var User = require("./models/user.js");


var cookieParser = require('cookie-parser'), 
    bodyParser = require('body-parser'),
    session= require('express-session'),
    methodOverride = require('method-override');


var app = express();

function findById(id, fn) {
  console.log("deserialize helper function findById");
  User.findOne("user", {'id': id}, function (err, user) {
    if (err) {
      return fn(err, null);
    } else {
      return fn(null, user);
    }
  });
}

// Passport session setup.
//   To support persistent login sessions, Passport needs to be able to
//   serialize users into and deserialize users out of the session.  Typically,
//   this will be as simple as storing the user ID when serializing, and finding
//   the user by ID when deserializing.  However, since this example does not
//   have a database of user records, the complete Google profile is serialized
//   and deserialized.
passport.serializeUser(function(user, done) {
  //do put 
  console.log("in serialize user is : " + JSON.stringify(user) + " and id is " + user.id);
  done(null, user.id);// primary key 
});

passport.deserializeUser(function(obj, done) { //obj= user.id 
  //find obj 
  findById(obj, function(err, user) {
    done(err, user);
  });
  //done(null, obj);
});


// passport.use(new GoogleStrategy({
//     returnURL: 'http://localhost:50000/auth/google/return',
//     realm: 'http://localhost:50000/'
//   },
//   function(identifier, profile, done) {
//     // asynchronous verification, for effect...
//     process.nextTick(function () {
      
//       // To keep the example simple, the user's Google profile is returned to
//       // represent the logged-in user.  In a typical application, you would want
//       // to associate the Google account with a user record in your database,
//       // and return that user instead.
//       profile.identifier = identifier;
//       return done(null, profile);
//     });
//   }
// ));

passport.use(new GoogleStrategy({
    clientID: '351029077337-lj4ufniaiasdp9gqs36iev730vsuhmsa.apps.googleusercontent.com',
    clientSecret: '<KEY>',
    callbackURL: "http://setmeetings-lisajung.rhcloud.com/auth/google/return"
  },
  function(token, tokenSecret, profile, done) {
    // asynchronous verification, for effect...
    profile.accessToken = token;

    process.nextTick(function () {
      console.log("in profile stuff");
      // To keep the example simple, the user's Google profile is returned to
      // represent the logged-in user.  In a typical application, you would want
      // to associate the Google account with a user record in your database,
      // and return that user instead.  
    

      //var newUser = { id: profile.id, displayName: profile.displayName, emails: profile.emails[0].value };
      
{'fraction_non_alphanumeric': 0.13725490196078433, 'fraction_numerical': 0.010509803921568627, 'mean_word_length': 3.0508259212198223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2685550', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1835, 'n_words': 557}