{"action":"created","comment":{"url":"https://api.github.com/repos/andela/vvida/pulls/comments/51113275","id":51113275,"diff_hunk":"@@ -13,38 +13,42 @@ module.exports = function(app, passport, config) {\n       process.nextTick(function() {\n         // check if the user exists in out database\n         Users.findOne({\n-            where: {\n-              'facebook_auth_id': profile.id\n-            },\n-            attributes: ['id', 'firstname', 'lastname', 'facebook_auth_id']\n-          }).then(function(user) {\n-            // If the user does not exist create one\n-            if (!user) {\n-              Users.build({\n-                  email: profile.emails[0].value,\n-                  role: 'user',\n-                  username: profile.username,\n-                  facebook_auth_id: profile.id,\n-                  facebook_auth_token: accessToken,\n-                  gender: profile.gender\n-                    // facebook: profile._json\n-                })\n-                .setFullName(profile.displayName)\n-                .save()\n-                .then(function(user) {\n-                  done(null, user);\n-                })\n-                .catch(function(err) {\n-                  if (err) {\n-                    return done(err);\n-                  }\n-                });\n-            }\n-            // The user was found, redirect to homepage\n-            else {\n-              done(null, profile);\n-            }\n-          })\n+          where: {\n+            $or: [{\n+              facebook_auth_id: profile.id,\n+            }, {\n+              email: profile.emails[0].value\n+            }]\n+          },\n+          attributes: ['id', 'firstname', 'lastname', 'gender', 'facebook_auth_id']","path":"server/services/auth/facebook.auth.js","position":43,"original_position":43,"commit_id":"2256565a3d544a3d0ce694f4b7edb11d512fb4a6","original_commit_id":"2256565a3d544a3d0ce694f4b7edb11d512fb4a6","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long.","created_at":"2016-01-28T11:58:55Z","updated_at":"2016-01-28T11:58:55Z","html_url":"https://github.com/andela/vvida/pull/154#discussion_r51113275","pull_request_url":"https://api.github.com/repos/andela/vvida/pulls/154","_links":{"self":{"href":"https://api.github.com/repos/andela/vvida/pulls/comments/51113275"},"html":{"href":"https://github.com/andela/vvida/pull/154#discussion_r51113275"},"pull_request":{"href":"https://api.github.com/repos/andela/vvida/pulls/154"}}},"pull_request":{"url":"https://api.github.com/repos/andela/vvida/pulls/154","id":57492156,"html_url":"https://github.com/andela/vvida/pull/154","diff_url":"https://github.com/andela/vvida/pull/154.diff","patch_url":"https://github.com/andela/vvida/pull/154.patch","issue_url":"https://api.github.com/repos/andela/vvida/issues/154","number":154,"state":"open","locked":false,"title":"Feature/fix google facebook auth","user":{"login":"andela-rekemezie","id":15085641,"avatar_url":"https://avatars.githubusercontent.com/u/15085641?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-rekemezie","html_url":"https://github.com/andela-rekemezie","followers_url":"https://api.github.com/users/andela-rekemezie/followers","following_url":"https://api.github.com/users/andela-rekemezie/following{/other_user}","gists_url":"https://api.github.com/users/andela-rekemezie/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-rekemezie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-rekemezie/subscriptions","organizations_url":"https://api.github.com/users/andela-rekemezie/orgs","repos_url":"https://api.github.com/users/andela-rekemezie/repos","events_url":"https://api.github.com/users/andela-rekemezie/events{/privacy}","received_events_url":"https://api.github.com/users/andela-rekemezie/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-28T11:58:24Z","updated_at":"2016-01-28T11:58:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"38c226904cadfb70d9cde557500a803712307269","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andela/vvida/pulls/154/commits","review_comments_url":"https://api.github.com/repos/andela/vvida/pulls/154/comments","review_comment_url":"https://api.github.com/repos/andela/vvida/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/vvida/issues/154/comments","statuses_url":"https://api.github.com/repos/andela/vvida/statuses/2256565a3d544a3d0ce694f4b7edb11d512fb4a6","head":{"label":"andela:feature/fix-google-facebook-auth","ref":"feature/fix-google-facebook-auth","sha":"2256565a3d544a3d0ce694f4b7edb11d512fb4a6","user":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":41422275,"name":"vvida","full_name":"andela/vvida","owner":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/vvida","description":"Yelp for Kenya [Production: https://vvida.herokuapp.com, Staging: https://vvida-staging.herokuapp.com]","fork":false,"url":"https://api.github.com/repos/andela/vvida","forks_url":"https://api.github.com/repos/andela/vvida/forks","keys_url":"https://api.github.com/repos/andela/vvida/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/vvida/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/vvida/teams","hooks_url":"https://api.github.com/repos/andela/vvida/hooks","issue_events_url":"https://api.github.com/repos/andela/vvida/issues/events{/number}","events_url":"https://api.github.com/repos/andela/vvida/events","assignees_url":"https://api.github.com/repos/andela/vvida/assignees{/user}","branches_url":"https://api.github.com/repos/andela/vvida/branches{/branch}","tags_url":"https://api.github.com/repos/andela/vvida/tags","blobs_url":"https://api.github.com/repos/andela/vvida/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/vvida/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/vvida/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/vvida/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/vvida/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/vvida/languages","stargazers_url":"https://api.github.com/repos/andela/vvida/stargazers","contributors_url":"https://api.github.com/repos/andela/vvida/contributors","subscribers_url":"https://api.github.com/repos/andela/vvida/subscribers","subscription_url":"https://api.github.com/repos/andela/vvida/subscription","commits_url":"https://api.github.com/repos/andela/vvida/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/vvida/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/vvida/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/vvida/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/vvida/contents/{+path}","compare_url":"https://api.github.com/repos/andela/vvida/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/vvida/merges","archive_url":"https://api.github.com/repos/andela/vvida/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/vvida/downloads","issues_url":"https://api.github.com/repos/andela/vvida/issues{/number}","pulls_url":"https://api.github.com/repos/andela/vvida/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/vvida/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/vvida/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/vvida/labels{/name}","releases_url":"https://api.github.com/repos/andela/vvida/releases{/id}","deployments_url":"https://api.github.com/repos/andela/vvida/deployments","created_at":"2015-08-26T11:36:19Z","updated_at":"2015-11-22T16:32:58Z","pushed_at":"2016-01-28T11:58:25Z","git_url":"git://github.com/andela/vvida.git","ssh_url":"git@github.com:andela/vvida.git","clone_url":"https://github.com/andela/vvida.git","svn_url":"https://github.com/andela/vvida","homepage":"","size":61806,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"base":{"label":"andela:develop","ref":"develop","sha":"df423db117275b9b2aab4cceaa443604b44b9bed","user":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":41422275,"name":"vvida","full_name":"andela/vvida","owner":{"login":"andela","id":4100206,"avatar_url":"https://avatars.githubusercontent.com/u/4100206?v=3","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/andela/vvida","description":"Yelp for Kenya [Production: https://vvida.herokuapp.com, Staging: https://vvida-staging.herokuapp.com]","fork":false,"url":"https://api.github.com/repos/andela/vvida","forks_url":"https://api.github.com/repos/andela/vvida/forks","keys_url":"https://api.github.com/repos/andela/vvida/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/vvida/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/vvida/teams","hooks_url":"https://api.github.com/repos/andela/vvida/hooks","issue_events_url":"https://api.github.com/repos/andela/vvida/issues/events{/number}","events_url":"https://api.github.com/repos/andela/vvida/events","assignees_url":"https://api.github.com/repos/andela/vvida/assignees{/user}","branches_url":"https://api.github.com/repos/andela/vvida/branches{/branch}","tags_url":"https://api.github.com/repos/andela/vvida/tags","blobs_url":"https://api.github.com/repos/andela/vvida/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/vvida/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/vvida/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/vvida/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/vvida/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/vvida/languages","stargazers_url":"https://api.github.com/repos/andela/vvida/stargazers","contributors_url":"https://api.github.com/repos/andela/vvida/contributors","subscribers_url":"https://api.github.com/repos/andela/vvida/subscribers","subscription_url":"https://api.github.com/repos/andela/vvida/subscription","commits_url":"https://api.github.com/repos/andela/vvida/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/vvida/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/vvida/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/vvida/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/vvida/contents/{+path}","compare_url":"https://api.github.com/repos/andela/vvida/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/vvida/merges","archive_url":"https://api.github.com/repos/andela/vvida/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/vvida/downloads","issues_url":"https://api.github.com/repos/andela/vvida/issues{/number}","pulls_url":"https://api.github.com/repos/andela/vvida/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/vvida/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/vvida/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/vvida/labels{/name}","releases_url":"https://api.github.com/repos/andela/vvida/releases{/id}","deployments_url":"https://api.github.com/repos/andela/vvida/deployments","created_at":"2015-08-26T11:36:19Z","updated_at":"2015-11-22T16:32:58Z","pushed_at":"2016-01-28T11:58:25Z","git_url":"git://github.com/andela/vvida.git","ssh_url":"git@github.com:andela/vvida.git","clone_url":"https://github.com/andela/vvida.git","svn_url":"https://github.com/andela/vvida","homepage":"","size":61806,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/vvida/pulls/154"},"html":{"href":"https://github.com/andela/vvida/pull/154"},"issue":{"href":"https://api.github.com/repos/andela/vvida/issues/154"},"comments":{"href":"https://api.github.com/repos/andela/vvida/issues/154/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/vvida/pulls/154/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/vvida/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/vvida/pulls/154/commits"},"statuses":{"href":"https://api.github.com/repos/andela/vvida/statuses/2256565a3d544a3d0ce694f4b7edb11d512fb4a6"}}}}