{"action":"created","comment":{"url":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments/208068857","pull_request_review_id":143806209,"id":208068857,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODA2ODg1Nw==","diff_hunk":"@@ -54,4 +53,54 @@ export default function signup(req, res, next) {\n       return next();\n     })\n     .catch(next);\n-}\n+};\n+\n+/**\n+ * Function validates user update inputs with customized error messages\n+ * @param {Object} req the request body\n+ * @param {Object} res the response body\n+ * @param {function} next a call to the next function\n+ * @returns {undefined}\n+ */\n+const updateUser = (req, res, next) => {\n+  const { decoded } = req.body;\n+  // check if all the declared fields are present in 'user' if not,\n+  // set the absent variables to false\n+  const { email, password, username } = req.body.user ? req.body.user : false;\n+  // Validation of user Inputs\n+  const validation = validator.updateUserRules({ email, password });\n+  if (validation) {\n+    return res.status(400).json({\n+      errors: validation,\n+    });\n+  }\n+  return User.find({\n+    where: {\n+      $or: [{ username }, { email }],\n+    },\n+  })\n+    .then((user) => {\n+      if (user) {\n+        const message = [];\n+        if (user.email === email\n+          && user.email !== decoded.email) message.push('Email provided is already taken');","path":"middleware/validator/users.js","position":66,"original_position":66,"commit_id":"1536ffdd4e1509bdfc389f978e7dc279db81f731","original_commit_id":"1536ffdd4e1509bdfc389f978e7dc279db81f731","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","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":"Line 86 exceeds the maximum line length of 80  max-len","created_at":"2018-08-07T00:44:06Z","updated_at":"2018-08-07T00:44:07Z","html_url":"https://github.com/andela/rivendell-ah/pull/27#discussion_r208068857","pull_request_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/27","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments/208068857"},"html":{"href":"https://github.com/andela/rivendell-ah/pull/27#discussion_r208068857"},"pull_request":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/andela/rivendell-ah/pulls/27","id":206549940,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2NTQ5OTQw","html_url":"https://github.com/andela/rivendell-ah/pull/27","diff_url":"https://github.com/andela/rivendell-ah/pull/27.diff","patch_url":"https://github.com/andela/rivendell-ah/pull/27.patch","issue_url":"https://api.github.com/repos/andela/rivendell-ah/issues/27","number":27,"state":"open","locked":false,"title":"#159204697 Implement create and update user profile","user":{"login":"megame24","id":30550427,"node_id":"MDQ6VXNlcjMwNTUwNDI3","avatar_url":"https://avatars3.githubusercontent.com/u/30550427?v=4","gravatar_id":"","url":"https://api.github.com/users/megame24","html_url":"https://github.com/megame24","followers_url":"https://api.github.com/users/megame24/followers","following_url":"https://api.github.com/users/megame24/following{/other_user}","gists_url":"https://api.github.com/users/megame24/gists{/gist_id}","starred_url":"https://api.github.com/users/megame24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/megame24/subscriptions","organizations_url":"https://api.github.com/users/megame24/orgs","repos_url":"https://api.github.com/users/megame24/repos","events_url":"https://api.github.com/users/megame24/events{/privacy}","received_events_url":"https://api.github.com/users/megame24/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n- set up the routes for creating and updating a user's profile\r\n- create password hash service to hash password on profile update\r\n- create middleware to validate input on profile update\r\n- create a helper function to help validate input\r\n- write tests for creating and updating a user's profile\r\n#### Description of Task to be completed?\r\nA user should be able to create and update his/her profile\r\n#### How should this be manually tested?\r\n- Install the app (`npm install`)\r\n- Start the application with (`npm start`)\r\n- Test POST `/api/profiles/:username` to retrieve the profile of a user with the specified username.\r\n- Test PUT `/api/user` route, providing optionally `email, username, password, bio, image`\r\n#### Any background context you want to provide?\r\n- N/A\r\n#### What are the relevant pivotal tracker stories?\r\n#159204697\r\n#### Screenshots (if appropriate)\r\n#### Questions:\r\nN/A","created_at":"2018-08-07T00:28:21Z","updated_at":"2018-08-07T00:44:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3330b1d0da06a24700770ea8d3df4065728c08cc","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/27/commits","review_comments_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/27/comments","review_comment_url":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/rivendell-ah/issues/27/comments","statuses_url":"https://api.github.com/repos/andela/rivendell-ah/statuses/1536ffdd4e1509bdfc389f978e7dc279db81f731","head":{"label":"andela:ft/159204697/create-profile","ref":"ft/159204697/create-profile","sha":"1536ffdd4e1509bdfc389f978e7dc279db81f731","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","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":141551362,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE1NTEzNjI=","name":"rivendell-ah","full_name":"andela/rivendell-ah","owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","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/rivendell-ah","description":null,"fork":false,"url":"https://api.github.com/repos/andela/rivendell-ah","forks_url":"https://api.github.com/repos/andela/rivendell-ah/forks","keys_url":"https://api.github.com/repos/andela/rivendell-ah/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/rivendell-ah/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/rivendell-ah/teams","hooks_url":"https://api.github.com/repos/andela/rivendell-ah/hooks","issue_events_url":"https://api.github.com/repos/andela/rivendell-ah/issues/events{/number}","events_url":"https://api.github.com/repos/andela/rivendell-ah/events","assignees_url":"https://api.github.com/repos/andela/rivendell-ah/assignees{/user}","branches_url":"https://api.github.com/repos/andela/rivendell-ah/branches{/branch}","tags_url":"https://api.github.com/repos/andela/rivendell-ah/tags","blobs_url":"https://api.github.com/repos/andela/rivendell-ah/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/rivendell-ah/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/rivendell-ah/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/rivendell-ah/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/rivendell-ah/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/rivendell-ah/languages","stargazers_url":"https://api.github.com/repos/andela/rivendell-ah/stargazers","contributors_url":"https://api.github.com/repos/andela/rivendell-ah/contributors","subscribers_url":"https://api.github.com/repos/andela/rivendell-ah/subscribers","subscription_url":"https://api.github.com/repos/andela/rivendell-ah/subscription","commits_url":"https://api.github.com/repos/andela/rivendell-ah/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/rivendell-ah/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/rivendell-ah/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/rivendell-ah/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/rivendell-ah/contents/{+path}","compare_url":"https://api.github.com/repos/andela/rivendell-ah/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/rivendell-ah/merges","archive_url":"https://api.github.com/repos/andela/rivendell-ah/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/rivendell-ah/downloads","issues_url":"https://api.github.com/repos/andela/rivendell-ah/issues{/number}","pulls_url":"https://api.github.com/repos/andela/rivendell-ah/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/rivendell-ah/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/rivendell-ah/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/rivendell-ah/labels{/name}","releases_url":"https://api.github.com/repos/andela/rivendell-ah/releases{/id}","deployments_url":"https://api.github.com/repos/andela/rivendell-ah/deployments","created_at":"2018-07-19T08:51:46Z","updated_at":"2018-08-06T10:38:38Z","pushed_at":"2018-08-07T00:43:58Z","git_url":"git://github.com/andela/rivendell-ah.git","ssh_url":"git@github.com:andela/rivendell-ah.git","clone_url":"https://github.com/andela/rivendell-ah.git","svn_url":"https://github.com/andela/rivendell-ah","homepage":null,"size":318,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"staging"}},"base":{"label":"andela:staging","ref":"staging","sha":"0a3610be63358a1a2f058efab9eea1c81999274a","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","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":141551362,"node_id":"MDEwOlJlcG9zaXRvcnkxNDE1NTEzNjI=","name":"rivendell-ah","full_name":"andela/rivendell-ah","owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","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/rivendell-ah","description":null,"fork":false,"url":"https://api.github.com/repos/andela/rivendell-ah","forks_url":"https://api.github.com/repos/andela/rivendell-ah/forks","keys_url":"https://api.github.com/repos/andela/rivendell-ah/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/rivendell-ah/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/rivendell-ah/teams","hooks_url":"https://api.github.com/repos/andela/rivendell-ah/hooks","issue_events_url":"https://api.github.com/repos/andela/rivendell-ah/issues/events{/number}","events_url":"https://api.github.com/repos/andela/rivendell-ah/events","assignees_url":"https://api.github.com/repos/andela/rivendell-ah/assignees{/user}","branches_url":"https://api.github.com/repos/andela/rivendell-ah/branches{/branch}","tags_url":"https://api.github.com/repos/andela/rivendell-ah/tags","blobs_url":"https://api.github.com/repos/andela/rivendell-ah/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/rivendell-ah/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/rivendell-ah/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/rivendell-ah/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/rivendell-ah/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/rivendell-ah/languages","stargazers_url":"https://api.github.com/repos/andela/rivendell-ah/stargazers","contributors_url":"https://api.github.com/repos/andela/rivendell-ah/contributors","subscribers_url":"https://api.github.com/repos/andela/rivendell-ah/subscribers","subscription_url":"https://api.github.com/repos/andela/rivendell-ah/subscription","commits_url":"https://api.github.com/repos/andela/rivendell-ah/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/rivendell-ah/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/rivendell-ah/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/rivendell-ah/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/rivendell-ah/contents/{+path}","compare_url":"https://api.github.com/repos/andela/rivendell-ah/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/rivendell-ah/merges","archive_url":"https://api.github.com/repos/andela/rivendell-ah/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/rivendell-ah/downloads","issues_url":"https://api.github.com/repos/andela/rivendell-ah/issues{/number}","pulls_url":"https://api.github.com/repos/andela/rivendell-ah/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/rivendell-ah/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/rivendell-ah/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/rivendell-ah/labels{/name}","releases_url":"https://api.github.com/repos/andela/rivendell-ah/releases{/id}","deployments_url":"https://api.github.com/repos/andela/rivendell-ah/deployments","created_at":"2018-07-19T08:51:46Z","updated_at":"2018-08-06T10:38:38Z","pushed_at":"2018-08-07T00:43:58Z","git_url":"git://github.com/andela/rivendell-ah.git","ssh_url":"git@github.com:andela/rivendell-ah.git","clone_url":"https://github.com/andela/rivendell-ah.git","svn_url":"https://github.com/andela/rivendell-ah","homepage":null,"size":318,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"staging"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/27"},"html":{"href":"https://github.com/andela/rivendell-ah/pull/27"},"issue":{"href":"https://api.github.com/repos/andela/rivendell-ah/issues/27"},"comments":{"href":"https://api.github.com/repos/andela/rivendell-ah/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/rivendell-ah/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/andela/rivendell-ah/statuses/1536ffdd4e1509bdfc389f978e7dc279db81f731"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"houndci-bot"}}