<commit_before>var passport = require('passport')
, LocalStrategy = require('passport-local').Strategy
, FacebookStrategy = require('passport-facebook').Strategy
, GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;

var validator = require('validator');
var options = require('./options-handler').options;
var log = require('./logger').log;

var model = require('./model');
var Page = model.Page;
var PageVersion = model.PageVersion;
var User = model.User;
var UserPassword = model.UserPassword;

exports.init = function(app) {

  // 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.
  //
  //   Both serializer and deserializer edited for Remember Me functionality
  passport.serializeUser(function(user, done) {
    done(null, user._id);
  });

  passport.deserializeUser(function(_id, done) {
    User.findById(_id , function (err, user) {
      done(err, user);
    });
  });

  if(options.login.auth.indexOf('facebook') > -1) {
    enableFacebookStrategy(passport);
  }

  if(options.login.auth.indexOf('google') > -1) {
    enableGoogleStrategy(passport);
  }

  if (options.login.auth.indexOf('plain') > -1 ||
      options.login.auth.indexOf('ldap') > -1) {
    enableLocalStrategy(passport);
  }

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

  app.get('/login', function(req, res){
    var redirect = req.param('redirect');
    if (!redirect) {
      redirect = '';
    }
    res.render(
      'login',
      {
        user: req.user,
        message: req.session.messages,
        redirectUrl:redirect,
        auth:options.login.auth,
        server:{
          projectName:options.serverName,
          user:req.user
        }
      }
    );<commit_msg>Do not show facebook/google login without clientID<commit_after>var passport = require('passport')
, LocalStrategy = require('passport-local').Strategy
, FacebookStrategy = require('passport-facebook').Strategy
, GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;

var validator = require('validator');
var options = require('./options-handler').options;
var log = require('./logger').log;

var model = require('./model');
var Page = model.Page;
var PageVersion = model.PageVersion;
var User = model.User;
var UserPassword = model.UserPassword;

exports.init = function(app) {

  // 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.
  //
  //   Both serializer and deserializer edited for Remember Me functionality
  passport.serializeUser(function(user, done) {
    done(null, user._id);
  });

  passport.deserializeUser(function(_id, done) {
    User.findById(_id , function (err, user) {
      done(err, user);
    });
  });

  if(options.login.auth.indexOf('facebook') > -1 &&
    options.login.facebook.clientID != 'INSERT_FACEBOOK_CLIENTID_HERE') {
    enableFacebookStrategy(passport);
  }

  if(options.login.auth.indexOf('google') > -1 &&
    options.login.google.clientID != 'INSERT_GOOGLE_CLIENTID_HERE') {
    enableGoogleStrategy(passport);
  }

  if (options.login.auth.indexOf('plain') > -1 ||
      options.login.auth.indexOf('ldap') > -1) {
    enableLocalStrategy(passport);
  }

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

  app.get('/login', function(req, res){
    var redirect = req.param('redirect');
    if (!redirect) {
      redirect = '';
    }
    res.render(
      'login',
      {
        user: req.user,
        message: req.session.messages,
        redirectUrl:redirect,
        auth:options.login.auth,
        server:{
          projectName:options.serverName,
          user:req.user
        }
      }
    );
{'fraction_non_alphanumeric': 0.13657463962863425, 'fraction_numerical': 0.002443195699975568, 'mean_word_length': 3.2468879668049793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3713653', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1204, 'n_words': 280}