<commit_before>var passport = require('passport');
var LdapStrategy = require('passport-ldapauth').Strategy;
var User = require('../models/user');
var Corpus = require('../models/corpus');
var fs = require('fs');
var path = require('path');


module.exports = function(app){
  passport.serializeUser(function(user, done) {
    done(null, user.id);
  });

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

  passport.use(new LdapStrategy({
    server: {
      url: 'ldaps://ldap.rit.edu',
      searchBase: 'ou=people,dc=rit,dc=edu',
      searchFilter: '(uid={{username}})'
    }
  },
  function(user, done){
    User.find({ dce: user.uid }).limit(1).exec(function(err, users){
      if(users.length === 0) {
        User.create({ dce: user.uid, name: user.cn }, function(err, user){
          files.forEach(function(file) {
            console.log(file);
            var corpusPath = path.join('assets','corpora', file);
            fs.readFile(corpusPath, function(err,data) {
              if(err) {
                console.log(err);
              }
              var corpus = {
                user_id: user._id,
                contents: data,
                title: file,<commit_msg>Fixing cross platform provided files<commit_after>var passport = require('passport');
var LdapStrategy = require('passport-ldapauth').Strategy;
var User = require('../models/user');
var Corpus = require('../models/corpus');
var fs = require('fs');
var path = require('path');
var os = require('os');


module.exports = function(app){
  passport.serializeUser(function(user, done) {
    done(null, user.id);
  });

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

  passport.use(new LdapStrategy({
    server: {
      url: 'ldaps://ldap.<EMAIL>',
      searchBase: 'ou=people,dc=rit,dc=edu',
      searchFilter: '(uid={{username}})'
    }
  },
  function(user, done){
    User.find({ dce: user.uid }).limit(1).exec(function(err, users){
      if(users.length === 0) {
        User.create({ dce: user.uid, name: user.cn }, function(err, user){
          var files = ['1928 News article', '2015 News article', 'Macbeth excerpt', 'My Bondage and My Freedom excerpt',
            'Romeo and Juliet excerpt', 'The Raven', 'Tom Sawyer excerpt'];
          files.forEach(function(file) {
            console.log(file);
            var corpusPath;
            if(os.platform() == 'win32') {
              corpusPath = path.join('.', 'assets','corpora', file);
            }
            else {
              corpusPath = path.join('.', 'assets','corpora', file);
            }
            fs.readFile(corpusPath, function(err,data) {
              if(err) {
                console.log(err);
              }
              var corpus = {
                user_id: user._id,
                contents: data,
                title: file,
{'fraction_non_alphanumeric': 0.16476126429051782, 'fraction_numerical': 0.004707464694014795, 'mean_word_length': 2.3691959229898076, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4283268', 'n_tokens_mistral': 942, 'n_tokens_neox': 908, 'n_words': 190}