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

var User = require('mongoose').model('User');

/**
 * Twitter Registration
 *
 * @param {Object} profile PassportJS's profile
 * @param {Function} fn Callback accepting `err` and `user`
 * @api public
 */

exports.facebook = function facebook (profile, accessToken, fn) {
  var user = new User();

  user.firstName = profile._json.first_name;
  user.lastName = profile._json.last_name;
  user.profiles.facebook = profile._json;
  user.email = profile.emails[0].value;
  user.emailValidated = true;
  user.avatar = profile.imageUrl;


  user.save(function(err) {
    return fn(err, user);
  });
}

/**
 * Get image url for profile
 *
 * @param {Object} profile
 * @param {String} email
 * @return {String} Profile image url (or `avatar`)
 * @api private
 */

function getImageUrl (profile, email) {
  return profile.imageUrl
    || 'http://gravatar.com/avatar/'.concat(md5(email)).concat('?d=mm&size=200')
    || '';
}

/**
 * MD5
 *
 * @param {String} source
 * @return {String} target
 * @api private
 */

function md5 (source) {
  return require('crypto')
    .createHash('md5')
    .update(source)
    .digest("hex");
}
<commit_msg>[facebook] Fixed user picture URL binding #711<commit_after>/**
 * Module dependencies.
 */

var User = require('mongoose').model('User');

/**
 * Twitter Registration
 *
 * @param {Object} profile PassportJS's profile
 * @param {Function} fn Callback accepting `err` and `user`
 * @api public
 */

exports.facebook = function facebook (profile, accessToken, fn) {
  var user = new User();

  user.firstName = profile._json.first_name;
  user.lastName = profile._json.last_name;
  user.profiles.facebook = profile._json;
  user.email = profile.emails[0].value;
  user.emailValidated = true;
  user.profilePictureUrl = profile.imageUrl;


  user.save(function(err) {
    return fn(err, user);
  });
}

/**
 * Get image url for profile
 *
 * @param {Object} profile
 * @param {String} email
 * @return {String} Profile image url (or `avatar`)
 * @api private
 */

function getImageUrl (profile, email) {
  return profile.imageUrl
    || 'http://gravatar.com/avatar/'.concat(md5(email)).concat('?d=mm&size=200')
    || '';
}

/**
 * MD5
 *
 * @param {String} source
 * @return {String} target
 * @api private
 */

function md5 (source) {
  return require('crypto')
    .createHash('md5')
    .update(source)
    .digest("hex");
}

{'fraction_non_alphanumeric': 0.16307053941908714, 'fraction_numerical': 0.007883817427385892, 'mean_word_length': 3.7181996086105675, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3363194', 'n_tokens_mistral': 813, 'n_tokens_neox': 791, 'n_words': 192}