<commit_before>"use strict";

var passport          = require('passport');
var session           = require('express-session');
var pg                = require('pg');
var pgSession         = require('connect-pg-simple')(session);
var uuid              = require('node-uuid');
var cookieParser      = require('cookie-parser');
var Strategies        = require('./oauthStrategies');
var User              = require('../models/users');

module.exports = (app,express) => {
  let database_url = process.env.DATABASE_URL || 'postgresql://localhost/fairshare';

  const sessionConfig = {
    genid: () => uuid.v1(),
    store:  new pgSession({
      pg       : pg,
      conString: database_url,
      tableName: 'sessions'
    }),
    secret: 'kitkat',
    resave: true,
    saveUninitialized: true
  };

  app.use(session(sessionConfig));
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(cookieParser('kitkat'));

  passport.serializeUser((user, done) => {
    return done(null, user.id);
  });

  passport.deserializeUser((id, done) => {
    User.getById({id: id})
    .then( userObj => {
      return done(null, userObj[0]);
    })
    .catch( err => {
      console.warn("err at deserialize:", err);
    });
  });<commit_msg>set resave to false in passport<commit_after>"use strict";

var passport          = require('passport');
var session           = require('express-session');
var pg                = require('pg');
var pgSession         = require('connect-pg-simple')(session);
var uuid              = require('node-uuid');
var cookieParser      = require('cookie-parser');
var Strategies        = require('./oauthStrategies');
var User              = require('../models/users');

module.exports = (app,express) => {
  let database_url = process.env.DATABASE_URL || 'postgresql://localhost/fairshare';

  const sessionConfig = {
    genid: () => uuid.v1(),
    store:  new pgSession({
      pg       : pg,
      conString: database_url,
      tableName: 'sessions'
    }),
    secret: 'kitkat',
    resave: false,
    saveUninitialized: false
  };

  app.use(session(sessionConfig));
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(cookieParser('kitkat'));

  passport.serializeUser((user, done) => {
    return done(null, user.id);
  });

  passport.deserializeUser((id, done) => {
    User.getById({id: id})
    .then( userObj => {
      return done(null, userObj[0]);
    })
    .catch( err => {
      console.warn("err at deserialize:", err);
    });
  });
{'fraction_non_alphanumeric': 0.1669316375198728, 'fraction_numerical': 0.001589825119236884, 'mean_word_length': 2.779279279279279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '88047', 'n_tokens_mistral': 778, 'n_tokens_neox': 770, 'n_words': 155}