{"action":"created","comment":{"url":"https://api.github.com/repos/andela/orophin-cfh/pulls/comments/147378009","pull_request_review_id":72465758,"id":147378009,"diff_hunk":"@@ -1,186 +1,187 @@\n-var mongoose = require('mongoose'),\n-    LocalStrategy = require('passport-local').Strategy,\n-    TwitterStrategy = require('passport-twitter').Strategy,\n-    FacebookStrategy = require('passport-facebook').Strategy,\n-    GitHubStrategy = require('passport-github').Strategy,\n-    GoogleStrategy = require('passport-google-oauth').OAuth2Strategy,\n-    User = mongoose.model('User'),\n-    config = require('./config');\n+const mongoose = require('mongoose'),\n+  LocalStrategy = require('passport-local').Strategy,\n+  TwitterStrategy = require('passport-twitter').Strategy,\n+  FacebookStrategy = require('passport-facebook').Strategy,\n+  GitHubStrategy = require('passport-github').Strategy,\n+  GoogleStrategy = require('passport-google-oauth').OAuth2Strategy,\n+  User = mongoose.model('User'),\n+  config = require('./config');\n \n+module.exports = (passport) => {\n+  // Serialize sessions\n+  passport.serializeUser((user, done) => {\n+    done(null, user.id);\n+  });\n \n-module.exports = function(passport) {\n-    //Serialize sessions\n-    passport.serializeUser(function(user, done) {\n-        done(null, user.id);\n+  passport.deserializeUser((id, done) => {\n+    User.findOne({\n+      _id: id\n+    }, (err, user) => {\n+      done(err, user);\n     });\n+  });\n \n-    passport.deserializeUser(function(id, done) {\n-        User.findOne({\n-            _id: id\n-        }, function(err, user) {\n-            user.email = null;\n-            user.facebook = null;\n-            user.hashed_password = null;\n-            done(err, user);\n-        });\n-    });\n-\n-    //Use local strategy\n-    passport.use(new LocalStrategy({\n-            usernameField: 'email',\n-            passwordField: 'password'\n-        },\n-        function(email, password, done) {\n-            User.findOne({\n-                email: email\n-            }, function(err, user) {\n-                if (err) {\n-                    return done(err);\n-                }\n-                if (!user) {\n-                    return done(null, false, {\n-                        message: 'Unknown user'\n-                    });\n-                }\n-                if (!user.authenticate(password)) {\n-                    return done(null, false, {\n-                        message: 'Invalid password'\n-                    });\n-                }\n-                user.email = null;\n-                user.hashed_password = null;\n-                return done(null, user);\n-            });\n+  // Use local strategy\n+  passport.use(new LocalStrategy(\n+    {\n+      usernameField: 'email',\n+      passwordField: 'password'\n+    },\n+    ((email, password, done) => {\n+      User.findOne({\n+        email\n+      }, (err, user) => {\n+        if (err) {\n+          return done(err);\n+        }\n+        if (!user) {\n+          return done(null, false, {\n+            message: 'Unknown user'\n+          });\n+        }\n+        if (!user.authenticate(password)) {\n+          return done(null, false, {\n+            message: 'Invalid password'\n+          });\n         }\n-    ));\n+        user.email = null;\n+        user.hashed_password = null;\n+        return done(null, user);\n+      });\n+    })\n+  ));\n \n-    //Use twitter strategy\n-    passport.use(new TwitterStrategy({\n-            consumerKey: process.env.TWITTER_CONSUMER_KEY || config.twitter.clientID,\n-            consumerSecret: process.env.TWITTER_CONSUMER_SECRET || config.twitter.clientSecret,\n-            callbackURL: config.twitter.callbackURL\n-        },\n-        function(token, tokenSecret, profile, done) {\n-            User.findOne({\n-                'twitter.id_str': profile.id\n-            }, function(err, user) {\n-                if (err) {\n-                    return done(err);\n-                }\n-                if (!user) {\n-                    user = new User({\n-                        name: profile.displayName,\n-                        username: profile.username,\n-                        provider: 'twitter',\n-                        twitter: profile._json\n-                    });\n-                    user.save(function(err) {\n-                        if (err) console.log(err);\n-                        return done(err, user);\n-                    });\n-                } else {\n-                    return done(err, user);\n-                }\n-            });\n+  // Use twitter strategy\n+  passport.use(new TwitterStrategy(\n+    {\n+      consumerKey: process.env.TWITTER_CONSUMER_KEY || config.twitter.clientID,\n+      consumerSecret: process.env.TWITTER_CONSUMER_SECRET || config.twitter.clientSecret,\n+      callbackURL: config.twitter.callbackURL\n+    },\n+    ((token, tokenSecret, profile, done) => {\n+      User.findOne({\n+        'twitter.id_str': profile.id\n+      }, (err, user) => {\n+        if (err) {\n+          return done(err);\n         }\n-    ));\n+        if (!user) {\n+          user = new User({\n+            name: profile.displayName,\n+            username: profile.username,\n+            provider: 'twitter',\n+            twitter: profile._json\n+          });\n+          user.save((err) => {\n+            if (err) console.log(err);\n+            return done(err, user);\n+          });\n+        } else {\n+          return done(err, user);\n+        }\n+      });\n+    })\n+  ));\n \n-    //Use facebook strategy\n-    passport.use(new FacebookStrategy({\n-            clientID: process.env.FB_CLIENT_ID || config.facebook.clientID,\n-            clientSecret: process.env.FB_CLIENT_SECRET || config.facebook.clientSecret,\n-            callbackURL: config.facebook.callbackURL\n-        },\n-        function(accessToken, refreshToken, profile, done) {\n-            User.findOne({\n-                'facebook.id': profile.id\n-            }, function(err, user) {\n-                if (err) {\n-                    return done(err);\n-                }\n-                if (!user) {\n-                    console.log(profile);\n-                    user = new User({\n-                        name: profile.displayName,\n-                        email: (profile.emails && profile.emails[0].value) || '',\n-                        username: profile.username,\n-                        provider: 'facebook',\n-                        facebook: profile._json\n-                    });\n-                    user.save(function(err) {\n-                        if (err) console.log(err);\n-                        user.facebook = null;\n-                        return done(err, user);\n-                    });\n-                } else {\n-                    user.facebook = null;\n-                    return done(err, user);\n-                }\n-            });\n+  // Use facebook strategy\n+  passport.use(new FacebookStrategy(\n+    {\n+      clientID: process.env.FB_CLIENT_ID || config.facebook.clientID,\n+      clientSecret: process.env.FB_CLIENT_SECRET || config.facebook.clientSecret,\n+      callbackURL: config.facebook.callbackURL\n+    },\n+    ((accessToken, refreshToken, profile, done) => {\n+      User.findOne({\n+        'facebook.id': profile.id\n+      }, (err, user) => {\n+        if (err) {\n+          return done(err);\n+        }\n+        if (!user) {\n+          console.log(profile);","path":"config/passport.js","position":212,"original_position":212,"commit_id":"26b047d088844e353614ca973ff7b2e44a10fa0d","original_commit_id":"26b047d088844e353614ca973ff7b2e44a10fa0d","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Unexpected console statement                              no-console","created_at":"2017-10-27T10:36:27Z","updated_at":"2017-10-27T10:36:27Z","html_url":"https://github.com/andela/orophin-cfh/pull/15#discussion_r147378009","pull_request_url":"https://api.github.com/repos/andela/orophin-cfh/pulls/15","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/andela/orophin-cfh/pulls/comments/147378009"},"html":{"href":"https://github.com/andela/orophin-cfh/pull/15#discussion_r147378009"},"pull_request":{"href":"https://api.github.com/repos/andela/orophin-cfh/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/andela/orophin-cfh/pulls/15","id":148687974,"html_url":"https://github.com/andela/orophin-cfh/pull/15","diff_url":"https://github.com/andela/orophin-cfh/pull/15.diff","patch_url":"https://github.com/andela/orophin-cfh/pull/15.patch","issue_url":"https://api.github.com/repos/andela/orophin-cfh/issues/15","number":15,"state":"open","locked":false,"title":"#151980414/#151980415 add jwt authentication","user":{"login":"williamolojede","id":23551907,"avatar_url":"https://avatars0.githubusercontent.com/u/23551907?v=4","gravatar_id":"","url":"https://api.github.com/users/williamolojede","html_url":"https://github.com/williamolojede","followers_url":"https://api.github.com/users/williamolojede/followers","following_url":"https://api.github.com/users/williamolojede/following{/other_user}","gists_url":"https://api.github.com/users/williamolojede/gists{/gist_id}","starred_url":"https://api.github.com/users/williamolojede/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williamolojede/subscriptions","organizations_url":"https://api.github.com/users/williamolojede/orgs","repos_url":"https://api.github.com/users/williamolojede/repos","events_url":"https://api.github.com/users/williamolojede/events{/privacy}","received_events_url":"https://api.github.com/users/williamolojede/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\nadd jwt authentication for  users for both login and signup\r\n\r\n#### Description of Task to be completed?\r\nN/A\r\n\r\n#### How should this be manually tested?\r\nvisit the signup and login page of the hosted application\r\n\r\n#### Any background context you want to provide?\r\nN/A\r\n\r\n#### What are the relevant pivotal tracker stories?\r\n#151980414 #151980415\r\n\r\n#### Screenshots (if appropriate)\r\nN/A\r\n\r\n#### Questions:\r\nN/A\r\n","created_at":"2017-10-25T14:40:49Z","updated_at":"2017-10-27T10:36:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14296e6ef0b9a889d41869d973fe1a423c9ee7f9","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela/orophin-cfh/pulls/15/commits","review_comments_url":"https://api.github.com/repos/andela/orophin-cfh/pulls/15/comments","review_comment_url":"https://api.github.com/repos/andela/orophin-cfh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/orophin-cfh/issues/15/comments","statuses_url":"https://api.github.com/repos/andela/orophin-cfh/statuses/26b047d088844e353614ca973ff7b2e44a10fa0d","head":{"label":"andela:feature/151980414/login-auth-jwt","ref":"feature/151980414/login-auth-jwt","sha":"26b047d088844e353614ca973ff7b2e44a10fa0d","user":{"login":"andela","id":4100206,"avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","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":106806178,"name":"orophin-cfh","full_name":"andela/orophin-cfh","owner":{"login":"andela","id":4100206,"avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","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/orophin-cfh","description":null,"fork":false,"url":"https://api.github.com/repos/andela/orophin-cfh","forks_url":"https://api.github.com/repos/andela/orophin-cfh/forks","keys_url":"https://api.github.com/repos/andela/orophin-cfh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/orophin-cfh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/orophin-cfh/teams","hooks_url":"https://api.github.com/repos/andela/orophin-cfh/hooks","issue_events_url":"https://api.github.com/repos/andela/orophin-cfh/issues/events{/number}","events_url":"https://api.github.com/repos/andela/orophin-cfh/events","assignees_url":"https://api.github.com/repos/andela/orophin-cfh/assignees{/user}","branches_url":"https://api.github.com/repos/andela/orophin-cfh/branches{/branch}","tags_url":"https://api.github.com/repos/andela/orophin-cfh/tags","blobs_url":"https://api.github.com/repos/andela/orophin-cfh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/orophin-cfh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/orophin-cfh/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/orophin-cfh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/orophin-cfh/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/orophin-cfh/languages","stargazers_url":"https://api.github.com/repos/andela/orophin-cfh/stargazers","contributors_url":"https://api.github.com/repos/andela/orophin-cfh/contributors","subscribers_url":"https://api.github.com/repos/andela/orophin-cfh/subscribers","subscription_url":"https://api.github.com/repos/andela/orophin-cfh/subscription","commits_url":"https://api.github.com/repos/andela/orophin-cfh/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/orophin-cfh/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/orophin-cfh/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/orophin-cfh/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/orophin-cfh/contents/{+path}","compare_url":"https://api.github.com/repos/andela/orophin-cfh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/orophin-cfh/merges","archive_url":"https://api.github.com/repos/andela/orophin-cfh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/orophin-cfh/downloads","issues_url":"https://api.github.com/repos/andela/orophin-cfh/issues{/number}","pulls_url":"https://api.github.com/repos/andela/orophin-cfh/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/orophin-cfh/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/orophin-cfh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/orophin-cfh/labels{/name}","releases_url":"https://api.github.com/repos/andela/orophin-cfh/releases{/id}","deployments_url":"https://api.github.com/repos/andela/orophin-cfh/deployments","created_at":"2017-10-13T09:40:28Z","updated_at":"2017-10-13T11:45:15Z","pushed_at":"2017-10-27T10:36:09Z","git_url":"git://github.com/andela/orophin-cfh.git","ssh_url":"git@github.com:andela/orophin-cfh.git","clone_url":"https://github.com/andela/orophin-cfh.git","svn_url":"https://github.com/andela/orophin-cfh","homepage":null,"size":19344,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"staging"}},"base":{"label":"andela:staging","ref":"staging","sha":"575990b85fb8ab7efd4d60e04aa482dec09bc343","user":{"login":"andela","id":4100206,"avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","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":106806178,"name":"orophin-cfh","full_name":"andela/orophin-cfh","owner":{"login":"andela","id":4100206,"avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","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/orophin-cfh","description":null,"fork":false,"url":"https://api.github.com/repos/andela/orophin-cfh","forks_url":"https://api.github.com/repos/andela/orophin-cfh/forks","keys_url":"https://api.github.com/repos/andela/orophin-cfh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/orophin-cfh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/orophin-cfh/teams","hooks_url":"https://api.github.com/repos/andela/orophin-cfh/hooks","issue_events_url":"https://api.github.com/repos/andela/orophin-cfh/issues/events{/number}","events_url":"https://api.github.com/repos/andela/orophin-cfh/events","assignees_url":"https://api.github.com/repos/andela/orophin-cfh/assignees{/user}","branches_url":"https://api.github.com/repos/andela/orophin-cfh/branches{/branch}","tags_url":"https://api.github.com/repos/andela/orophin-cfh/tags","blobs_url":"https://api.github.com/repos/andela/orophin-cfh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/orophin-cfh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/orophin-cfh/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/orophin-cfh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/orophin-cfh/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/orophin-cfh/languages","stargazers_url":"https://api.github.com/repos/andela/orophin-cfh/stargazers","contributors_url":"https://api.github.com/repos/andela/orophin-cfh/contributors","subscribers_url":"https://api.github.com/repos/andela/orophin-cfh/subscribers","subscription_url":"https://api.github.com/repos/andela/orophin-cfh/subscription","commits_url":"https://api.github.com/repos/andela/orophin-cfh/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/orophin-cfh/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/orophin-cfh/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/orophin-cfh/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/orophin-cfh/contents/{+path}","compare_url":"https://api.github.com/repos/andela/orophin-cfh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/orophin-cfh/merges","archive_url":"https://api.github.com/repos/andela/orophin-cfh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/orophin-cfh/downloads","issues_url":"https://api.github.com/repos/andela/orophin-cfh/issues{/number}","pulls_url":"https://api.github.com/repos/andela/orophin-cfh/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/orophin-cfh/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/orophin-cfh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/orophin-cfh/labels{/name}","releases_url":"https://api.github.com/repos/andela/orophin-cfh/releases{/id}","deployments_url":"https://api.github.com/repos/andela/orophin-cfh/deployments","created_at":"2017-10-13T09:40:28Z","updated_at":"2017-10-13T11:45:15Z","pushed_at":"2017-10-27T10:36:09Z","git_url":"git://github.com/andela/orophin-cfh.git","ssh_url":"git@github.com:andela/orophin-cfh.git","clone_url":"https://github.com/andela/orophin-cfh.git","svn_url":"https://github.com/andela/orophin-cfh","homepage":null,"size":19344,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/orophin-cfh/pulls/15"},"html":{"href":"https://github.com/andela/orophin-cfh/pull/15"},"issue":{"href":"https://api.github.com/repos/andela/orophin-cfh/issues/15"},"comments":{"href":"https://api.github.com/repos/andela/orophin-cfh/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/orophin-cfh/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/orophin-cfh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/orophin-cfh/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/andela/orophin-cfh/statuses/26b047d088844e353614ca973ff7b2e44a10fa0d"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"houndci-bot"}}