<commit_before>/**
 * Module dependencies.
 */

var log = require('debug')('registration')
  , utils = require('lib/utils')
  , mongoose = require('mongoose');

/**
 * Citizen Model
 */

var Citizen = mongoose.model('Citizen');


/**
 * Local Registration
 *
 * @param {Object} profile object with local registration data
 * @param {Function} callback Callback accepting `err` and `citizen`
 * @api public
 */

exports.local = function local (profile, callback) {
  var citizen = new Citizen(profile);

  log('new citizen [%s] from Local signup [%s]', citizen.id, profile.username);

  citizen.avatar = 'http://gravatar.com/avatar/'.concat(utils.md5(citizen.email)).concat('?d=mm&size=200');

  Citizen.register(citizen.toJSON(), profile.password, function(err, citizen) {
    if (err) return callback(err);
    log('Saved citizen [%s]', citizen.id);
    return callback(err, citizen);
  });
}

/**
 * Facebook Registration
 *
 * @param {Object} profile PassportJS's profile
 * @param {Function} callback Callback accepting `err` and `citizen`
 * @api public
 */

exports.facebook = function facebook (profile, callback) {
  var citizen = new Citizen();

  log('new citizen [%s] from Facebook profile [%s]', citizen.id, profile.username);

  citizen.firstName = profile.name.givenName;
  citizen.lastName = profile.name.familyName;
  // here we should check email. Send email verification and stuff
  citizen.email = profile.emails[0].value;
  citizen.profiles.facebook = profile;
  citizen.avatar = profile.imageUrl || 'http://gravatar.com/avatar/'.concat(utils.md5(citizen.email)).concat('?d=mm&size=200') || '';

  citizen.save(function(err) {
    log('Saved citizen [%s]', citizen.id);
    return callback(err, citizen);
  });
}<commit_msg>[registration] - Update log<commit_after>/**
 * Module dependencies.
 */

var log = require('debug')('registration')
  , utils = require('lib/utils')
  , mongoose = require('mongoose');

/**
 * Citizen Model
 */

var Citizen = mongoose.model('Citizen');


/**
 * Local Registration
 *
 * @param {Object} profile object with local registration data
 * @param {Function} callback Callback accepting `err` and `citizen`
 * @api public
 */

exports.local = function local (profile, callback) {
  var citizen = new Citizen(profile);

  log('new citizen [%s] from Local signup [%s]', citizen.id, profile.email);

  citizen.avatar = 'http://gravatar.com/avatar/'.concat(utils.md5(citizen.email)).concat('?d=mm&size=200');

  Citizen.register(citizen.toJSON(), profile.password, function(err, citizen) {
    if (err) return callback(err);
    log('Saved citizen [%s]', citizen.id);
    return callback(err, citizen);
  });
}

/**
 * Facebook Registration
 *
 * @param {Object} profile PassportJS's profile
 * @param {Function} callback Callback accepting `err` and `citizen`
 * @api public
 */

exports.facebook = function facebook (profile, callback) {
  var citizen = new Citizen();

  log('new citizen [%s] from Facebook profile [%s]', citizen.id, profile.username);

  citizen.firstName = profile.name.givenName;
  citizen.lastName = profile.name.familyName;
  // here we should check email. Send email verification and stuff
  citizen.email = profile.emails[0].value;
  citizen.profiles.facebook = profile;
  citizen.avatar = profile.imageUrl || 'http://gravatar.com/avatar/'.concat(utils.md5(citizen.email)).concat('?d=mm&size=200') || '';

  citizen.save(function(err) {
    log('Saved citizen [%s]', citizen.id);
    return callback(err, citizen);
  });
}
{'fraction_non_alphanumeric': 0.162046298942555, 'fraction_numerical': 0.005144326950557302, 'mean_word_length': 4.3929121725731894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6782689', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1089, 'n_words': 270}