<commit_before>var passport = require('passport'),
    LocalStrategy = require('passport-local').Strategy,
    GoogleStrategy = require('passport-google-oauth2').Strategy;
    GitHubStrategy = require('passport-github').Strategy;
    session = require('express-session'),
    expressValidator = require('express-validator'),
    bcrypt = require('bcryptjs'),
    flash = require('connect-flash'),
    cookieParser = require('cookie-parser'),
    bodyParser = require("body-parser"),
    User = require('../models/user'),
    findOrCreate = require("mongoose-findorcreate");

    //UserSchema.plugin(findOrCreate);

module.exports = function(app) {

  // use cookies to transmit session info back and forth
  app.use(cookieParser('s00pers3kret'));

  // enable reading data from form POST requests and JSON data
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());

  app.use(bodyParser());
  app.use(expressValidator());

  app.use(flash());

  //use session
  app.use(session(
    { cookie: { maxAge: 60000 },
      secret: 's00pers3kret',
      resave: false,
      saveUninitialized: false}));

  app.use(passport.initialize());
  app.use(passport.session());

  // Passport Local Strategy
  passport.use(new LocalStrategy(function(username, password, done) {
    console.log("login credentials: " + username + password);
      User.findByUsername(username, function(err, user){
        if(err) throw err;
        if(!user){
          console.log("no such user.")
          return done(null, false, {message: 'Invalid username or password'});
        }
        bcrypt.compare(password, user.passwordHash, function(err, isMatch){
          console.log("comparing: " + password + " with " + user.passwordHash);
          if(err) throw err;
          if(isMatch){
            console.log("isMatch. User returned: " + user);
            return done(null, user);
          } else {
            console.log("not match");
            return done(null, false, {message: 'Invalid username or password'});
          }
        });
      });
  }));

// Passport Google Strategy
  passport.use(new GoogleStrategy({
    clientID        : '913375318653-dqg1upddvrlpfssnpou9m519nh5p9vec.apps.googleusercontent.com',
    clientSecret    : '<KEY>',
    callbackURL     : 'http://aida-webapp.herokuapp.com/google/callback',
    passReqToCallback   : true
  },
  function(request, accessToken, refreshToken, profile, done) {
    User.findOrCreate({ googleId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

//Passport Github Strategy
  passport.use(new GitHubStrategy({
    clientID        : 'e9a26732aa4e50ddfd37',<commit_msg>try fixing heroku<commit_after>var passport = require('passport'),
    LocalStrategy = require('passport-local').Strategy,
    GoogleStrategy = require('passport-google-oauth2').Strategy;
    GitHubStrategy = require('passport-github').Strategy;
    session = require('express-session'),
    expressValidator = require('express-validator'),
    bcrypt = require('bcryptjs'),
    flash = require('connect-flash'),
    cookieParser = require('cookie-parser'),
    bodyParser = require("body-parser"),
    User = require('../models/user'),
    findOrCreate = require("mongoose-findorcreate");

    //UserSchema.plugin(findOrCreate);

module.exports = function(app) {

  // use cookies to transmit session info back and forth
  app.use(cookieParser('s00pers3kret'));

  // enable reading data from form POST requests and JSON data
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());

  app.use(bodyParser());
  app.use(expressValidator());

  app.use(flash());

  //use session
  app.use(session(
    { cookie: { maxAge: 60000 },
      secret: 's00pers3kret',
      resave: false,
      saveUninitialized: false}));

  app.use(passport.initialize());
  app.use(passport.session());

  // Passport Local Strategy
  passport.use(new LocalStrategy(function(username, password, done) {
    console.log("login credentials: " + username + password);
      User.findByUsername(username, function(err, user){
        if(err) throw err;
        if(!user){
          console.log("no such user.")
          return done(null, false, {message: 'Invalid username or password'});
        }
        bcrypt.compare(password, user.passwordHash, function(err, isMatch){
          console.log("comparing: " + password + " with " + user.passwordHash);
          if(err) throw err;
          if(isMatch){
            console.log("isMatch. User returned: " + user);
            return done(null, user);
          } else {
            console.log("not match");
            return done(null, false, {message: 'Invalid username or password'});
          }
        });
      });
  }));

// Passport Google Strategy
  passport.use(new GoogleStrategy({
    clientID        : '913375318653-dqg1upddvrlpfssnpou9m519nh5p9vec.apps.googleusercontent.com',
    clientSecret    : '<KEY>',
    callbackURL     : 'http://localhost:3000/google/callback',
    passReqToCallback   : true
  },
  function(request, accessToken, refreshToken, profile, done) {
    User.findOrCreate({ googleId: profile.id }, function (err, user) {
      return done(err, user);
    });
  }
));

//Passport Github Strategy
  passport.use(new GitHubStrategy({
    clientID        : 'e9a26732aa4e50ddfd37',
{'fraction_non_alphanumeric': 0.1417087306038512, 'fraction_numerical': 0.016451673209945783, 'mean_word_length': 3.1862284820031297, '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': '2229194', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1567, 'n_words': 325}