{"size": 1431, "ext": "js", "max_stars_repo_path": "collections/users.js", "max_stars_repo_name": "sharett/balance", "max_stars_repo_stars_event_min_datetime": "2018-07-17T14:10:18.000Z", "max_stars_repo_stars_event_max_datetime": "2018-07-17T14:10:18.000Z", "max_issues_repo_path": "collections/users.js", "max_issues_repo_name": "sharett/balance", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "collections/users.js", "max_forks_repo_name": "sharett/balance", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.2040816327, "max_line_length": 85, "alphanum_fraction": 0.6254367575}
///////////////////////////////////////////////////////////////////////////////
// Users

displayName = function (user) {
  if (user.profile) {
		if (user.profile.nickname)
			return user.profile.nickname;
		if (user.profile.name)
			return user.profile.name;
  }			
  return 'No name';
};

balance_fullName = function (user) {
	if (user.profile && user.profile.name)
			return user.profile.name;
  
  return 'No name';
};

var contactEmail = function (user) {
  if (user.emails && user.emails.length)
    return user.emails[0].address;
  if (user.services && user.services.facebook && user.services.facebook.email)
    return user.services.facebook.email;
  return null;
};

Meteor.methods({
  // options should include: name, nickname
  updateProfile: function (options) {
    options = options || {};
    if (! (typeof options.name === "string" && options.name.length))
      throw new Meteor.Error(400, "A name is required.");
    if (options.name.length > 100)
      throw new Meteor.Error(413, "The name must be 100 characters or shorter.");
    if (options.nickname.length > 100)
      throw new Meteor.Error(413, "The nickname must be 100 characters or shorter.");
    if (! this.userId)
      throw new Meteor.Error(403, "You must be logged in to update your profile.");

    return Meteor.users.update(this.userId, 
			{$set: {
				'profile.name': options.name,
				'profile.nickname': options.nickname,
			}});
  },
});
