'use strict';

var User = require('../schemas/userSchema.js').User;

function createNewUserFromGithub(profile) {
  // passport normalizes the response.
  var raw = profile._json;

  var user = new User({
    githubId: raw.id,
    name: raw.name,
    avatar_url: raw.avatar_url
  });

  user.save();
}

function fetchUserByGithubId(data) {
  return User.findOne({
    githubId: data.githubId
  }).exec();
}

exports.findOrCreateUser = function (profile) {
  return fetchUserByGithubId({
    githubId: profile.id
  }).then(function (user) {
      return user || createNewUserFromGithub(profile);
    }
  });
};

exports.fetchUserById = function (id) {
  return User.findById(id).exec();
};

@@ -536,18 +536,16 @@
 ) %7B%0A    
-  
 return u
@@ -589,14 +589,8 @@
 e);%0A
-    %7D%0A
   %7D)
@@ -668,13 +668,12 @@
 ).exec();%0A%7D;
-%0A

Fix brackets