<commit_before>var Datastore = require('nedb');
var Handlebars = require('handlebars');
var moment = require("moment");

var linkify = require('linkifyjs');
require('linkifyjs/plugins/hashtag')(linkify); // optional 
var linkifyHtml = require('linkifyjs/html');

var db = new Datastore({
  filename: 'words.db',
  autoload: true
});

var users = new Datastore({
  filename: 'users.db',
  autoload: true
});

var util = require("util");
var passport = require('passport'),
  LocalStrategy = require('passport-local').Strategy;

passport.use(new LocalStrategy(
  function (username, password, done) {
    users.findOne({
      "$or": [
        {
          username: username
        }, {
          email: username
        }
    ]
    }, function (err, user) {
      if (err) {
        return done(err);
      }
      if (!user) {
        return done(null, false, {
          message: 'Incorrect username.'
        });
      }
      if (user.password !== password) {
        return done(null, false, {
          message: 'Incorrect password.'
        });
      }
      return done(null, user);
    });
  }));

var debug = function (thing) {
  console.log(util.inspect(thing, {
    depth: 10
  }))

}

var server = require('http').createServer(),
  WebSocketServer = require('ws').Server,
  ws = new WebSocketServer({
    server: server
  }),
  express = require('express'),
  app = express(),
  bodyParser = require('body-parser'),
  port = 7777;

app.use(bodyParser.urlencoded({
  extended: false
}));

var flash = require('express-flash');

app.use(flash());

passport.serializeUser(function (user, done) {
  done(null, user.username);
});

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

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

app.use(bodyParser.json());

var session = require('express-session');

app.use(session({
  secret: 'keyboard cat',
  resave: false,
  saveUninitialized: true
}));

// Create new user

app.post("/meta/newUser", function (req, res) {

  if (!req.body.username || !req.body.password || !req.body.email) {

    return res.redirect("/meta/login");

  }

  var account = {
    username: req.body.username.toLowerCase(),
    password: <PASSWORD>,
    email: req.body.email.toLowerCase()
  }

  users.insert(account, function (err, newDoc) {

    res.redirect("/");

  });<commit_msg>Safer cookie key - goodbye keyboard cat<commit_after>var Datastore = require('nedb');
var Handlebars = require('handlebars');
var moment = require("moment");

var linkify = require('linkifyjs');
require('linkifyjs/plugins/hashtag')(linkify); // optional 
var linkifyHtml = require('linkifyjs/html');

var db = new Datastore({
  filename: 'words.db',
  autoload: true
});

var users = new Datastore({
  filename: 'users.db',
  autoload: true
});

var util = require("util");
var passport = require('passport'),
  LocalStrategy = require('passport-local').Strategy;

passport.use(new LocalStrategy(
  function (username, password, done) {
    users.findOne({
      "$or": [
        {
          username: username
        }, {
          email: username
        }
    ]
    }, function (err, user) {
      if (err) {
        return done(err);
      }
      if (!user) {
        return done(null, false, {
          message: 'Incorrect username.'
        });
      }
      if (user.password !== password) {
        return done(null, false, {
          message: 'Incorrect password.'
        });
      }
      return done(null, user);
    });
  }));

var debug = function (thing) {
  console.log(util.inspect(thing, {
    depth: 10
  }))

}

var server = require('http').createServer(),
  WebSocketServer = require('ws').Server,
  ws = new WebSocketServer({
    server: server
  }),
  express = require('express'),
  app = express(),
  bodyParser = require('body-parser'),
  port = 7777;

app.use(bodyParser.urlencoded({
  extended: false
}));

var flash = require('express-flash');

app.use(flash());

passport.serializeUser(function (user, done) {
  done(null, user.username);
});

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

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

app.use(bodyParser.json());

var session = require('express-session');

var crypto = require('crypto');

app.use(session({
  secret: crypto.randomBytes(8).toString('hex'),
  resave: false,
  saveUninitialized: true
}));

// Create new user

app.post("/meta/newUser", function (req, res) {

  if (!req.body.username || !req.body.password || !req.body.email) {

    return res.redirect("/meta/login");

  }

  var account = {
    username: req.body.username.toLowerCase(),
    password: <PASSWORD>,
    email: req.body.email.toLowerCase()
  }

  users.insert(account, function (err, newDoc) {

    res.redirect("/");

  });
{'fraction_non_alphanumeric': 0.16932841932841933, 'fraction_numerical': 0.0026617526617526617, 'mean_word_length': 3.1823630136986303, 'pattern_counts': {'":': 2, '<': 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': '4770118', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1564, 'n_words': 339}