<commit_before>
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');

// -----------------------------------
// Schema
//   set email and username as sparse - this is to allow null values for
//   social registrations
// -----------------------------------
var userSchema = new mongoose.Schema({
  email: { type: String, trim: true, unique: true, sparse: true },
  username: { type: String, trim: true, unique: true, sparse: true },
  name: { type: String, trim: true },
  password: String,
  provider: {
    type: String,
    enum: ['local', 'github', 'twitter', 'facebook', 'google']
  },
  facebook: {},
  twitter: {},
  github: {},
  google: {}
});

// -----------------------------------
// Validators
//   note that we dont validate uniqueness here. that is handled in the controller
//   http://nraj.tumblr.com/post/38706353543/handling-uniqueness-validation-in-mongo-mongoose
//   https://groups.google.com/forum/?fromgroups=#!topic/mongoose-orm/BX7kz0BwLjk
// -----------------------------------
// define validation functions
var validateRequired = function(value) {
  return (value && value.length);
};
var validateEmail = function(value) {
  return value.match(/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/);
};
var validateAlphanumericUnderscore = function(value) {
  return value.match(/^[a-zA-Z0-9_.]+$/);
};
var validatePasswordLength = function(value) {
  return value.length >= 3;
};<commit_msg>add indexes to facebook/twitter id and remove google/github<commit_after>
var mongoose = require('mongoose');
var bcrypt = require('bcrypt-nodejs');

// -----------------------------------
// Schema
//   set email and username as sparse - this is to allow null values for
//   social registrations
// -----------------------------------
var userSchema = new mongoose.Schema({
  email: { type: String, trim: true, unique: true, sparse: true },
  username: { type: String, trim: true, unique: true, sparse: true },
  name: { type: String, trim: true },
  password: String,
  provider: {
    type: String,
    enum: ['local', 'facebook', 'twitter']
  },
  facebook: {
    id: { type: String, unique: true, sparse: true }
  },
  twitter: {
    id_str: { type: String, unique: true, sparse: true }
  }
});

// -----------------------------------
// Validators
//   note that we dont validate uniqueness here. that is handled in the controller
//   http://nraj.tumblr.com/post/38706353543/handling-uniqueness-validation-in-mongo-mongoose
//   https://groups.google.com/forum/?fromgroups=#!topic/mongoose-orm/BX7kz0BwLjk
// -----------------------------------
// define validation functions
var validateRequired = function(value) {
  return (value && value.length);
};
var validateEmail = function(value) {
  return value.match(/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/);
};
var validateAlphanumericUnderscore = function(value) {
  return value.match(/^[a-zA-Z0-9_.]+$/);
};
var validatePasswordLength = function(value) {
  return value.length >= 3;
};
{'fraction_non_alphanumeric': 0.32415375788869766, 'fraction_numerical': 0.03270223752151463, 'mean_word_length': 2.493987975951904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3985155', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1251, 'n_words': 229}