{"action":"created","comment":{"url":"https://api.github.com/repos/andela/firestar-backend/pulls/comments/317530075","pull_request_review_id":279497405,"id":317530075,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDMxNzUzMDA3NQ==","diff_hunk":"@@ -0,0 +1,132 @@\n+import { Router } from 'express';\n+import moment from 'moment';\n+import crypto from 'crypto';\n+import Validation from '../validation';\n+import { sendResetMail, sendSignupMail } from '../services/sendMail';\n+import { errorResponse, successResponse } from '../utils/response';\n+import Hash from '../utils/hash';\n+import models from '../models';\n+\n+const { User, Login, Reset } = models;\n+\n+const forgotPassword = (req, res) => {\n+  const { errors, isValid } = Validation.validateEmail(req.body);\n+\n+  // Check validation\n+  if (!isValid) {\n+    return errorResponse(res, 400, errors);\n+  }\n+\n+  const { email } = req.body;\n+\n+  // Find user by email\n+  User.findOne({ where: { email } }).then((user) => {","path":"src/controllers/userController.js","position":23,"original_position":23,"commit_id":"e271d26573ef792fe31da9b63d498a6edac4769d","original_commit_id":"e271d26573ef792fe31da9b63d498a6edac4769d","user":{"login":"rovilay","id":27569442,"node_id":"MDQ6VXNlcjI3NTY5NDQy","avatar_url":"https://avatars0.githubusercontent.com/u/27569442?v=4","gravatar_id":"","url":"https://api.github.com/users/rovilay","html_url":"https://github.com/rovilay","followers_url":"https://api.github.com/users/rovilay/followers","following_url":"https://api.github.com/users/rovilay/following{/other_user}","gists_url":"https://api.github.com/users/rovilay/gists{/gist_id}","starred_url":"https://api.github.com/users/rovilay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rovilay/subscriptions","organizations_url":"https://api.github.com/users/rovilay/orgs","repos_url":"https://api.github.com/users/rovilay/repos","events_url":"https://api.github.com/users/rovilay/events{/privacy}","received_events_url":"https://api.github.com/users/rovilay/received_events","type":"User","site_admin":false},"body":"I thought we discussed using `async/await` and `try/catch`.","created_at":"2019-08-26T09:41:45Z","updated_at":"2019-08-26T09:41:45Z","html_url":"https://github.com/andela/firestar-backend/pull/25#discussion_r317530075","pull_request_url":"https://api.github.com/repos/andela/firestar-backend/pulls/25","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/andela/firestar-backend/pulls/comments/317530075"},"html":{"href":"https://github.com/andela/firestar-backend/pull/25#discussion_r317530075"},"pull_request":{"href":"https://api.github.com/repos/andela/firestar-backend/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/andela/firestar-backend/pulls/25","id":309736291,"node_id":"MDExOlB1bGxSZXF1ZXN0MzA5NzM2Mjkx","html_url":"https://github.com/andela/firestar-backend/pull/25","diff_url":"https://github.com/andela/firestar-backend/pull/25.diff","patch_url":"https://github.com/andela/firestar-backend/pull/25.patch","issue_url":"https://api.github.com/repos/andela/firestar-backend/issues/25","number":25,"state":"open","locked":false,"title":"#167730744 Implements Reset password feature","user":{"login":"conquext","id":28393660,"node_id":"MDQ6VXNlcjI4MzkzNjYw","avatar_url":"https://avatars2.githubusercontent.com/u/28393660?v=4","gravatar_id":"","url":"https://api.github.com/users/conquext","html_url":"https://github.com/conquext","followers_url":"https://api.github.com/users/conquext/followers","following_url":"https://api.github.com/users/conquext/following{/other_user}","gists_url":"https://api.github.com/users/conquext/gists{/gist_id}","starred_url":"https://api.github.com/users/conquext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conquext/subscriptions","organizations_url":"https://api.github.com/users/conquext/orgs","repos_url":"https://api.github.com/users/conquext/repos","events_url":"https://api.github.com/users/conquext/events{/privacy}","received_events_url":"https://api.github.com/users/conquext/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n* Resets user password by sending a cryptographically stamped token to the email of a registered user on request. The token allows a user to set new password. Only a valid user can reset passwords, invalid requests are sent links to sign up on the website\r\n#### Description of Task to be completed?\r\n* Sequelize Models for Login, and Reset table and relations\r\n* Seed users data to test functionality\r\n* Unit test to verify proper validations and error handling\r\n* Email provider to handle secured delivery of reset links\r\n#### How should this be manually tested?\r\n* git clone this branch `ft-reset-password-167730744`\r\n* cd to the project\r\n* run `npm install`\r\n\r\n* set PORT on .env to 4000\r\n * set LOCALHOST on .env to localhost:4000\r\n* set TOKENEXPIRY to any integer value\r\n* EMAIL to an gmail address your control\r\n* CLIENT_URL links to an heroku url where the api is served or any local server\r\n*DATABASE_URL and DATABASE_URL_TEST [In this format: postgres://db_name:db_pass@host:port/db_name\r\n> Register for an account on sendgrid.com and create API key at https://app.sendgrid.com/settings/api_keys, then set the following environment variables\r\n>* SENDGRIP_API\r\n>*CLIENT_URL=\"localhost:4000/\"  \r\n\r\n\r\nAlso in your .env, supply this field with valid information to receive reset links\r\nYOUR_EMAIL=\"\"\r\nSOME_PASSWORD=\"\" (Must be greater than 3 characters)\r\n\r\n* run npm start:dev\r\n\r\n* go to localhost:4000/api/forgotpassword (HTTP METHOD: POST) and supply one of the emails you sync with\r\n* then you should get an email with a rest link\r\n* then copy the link in your email into postman, set {password and confirmPassword}, extract only the relative path and replace the base path with your localhost\r\n* also try invalid data to catch errors\r\n\r\nTo test resetpassword\r\n* From the link in your email, replace firestar_backend.herokuapp with localhost:4000/api/\r\n\r\n#### Any background context you want to provide?\r\n* Users may be lose access to their account, but are able to retrieve it with their email. Emails provide proof of authentication and obfuscate the membership of the network to only the members.\r\n\r\n#### What are the relevant pivotal tracker stories?\r\n* [#167730744](https://www.pivotaltracker.com/n/projects/2382004/stories/167730744)\r\n\r\n#### Screenshots or gifs (if appropriate)\r\n* \r\n![image](https://user-images.githubusercontent.com/28393660/63473027-f6a40580-c46b-11e9-9f58-b59ef90bc228.png)\r\n\r\n#### Questions:\r\n* N/A\r\n","created_at":"2019-08-22T00:30:30Z","updated_at":"2019-08-26T09:41:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c4ca31d56ff3ec8787aafa8c018e5f2d2d76b491","assignee":null,"assignees":[],"requested_reviewers":[{"login":"ola357","id":38467005,"node_id":"MDQ6VXNlcjM4NDY3MDA1","avatar_url":"https://avatars0.githubusercontent.com/u/38467005?v=4","gravatar_id":"","url":"https://api.github.com/users/ola357","html_url":"https://github.com/ola357","followers_url":"https://api.github.com/users/ola357/followers","following_url":"https://api.github.com/users/ola357/following{/other_user}","gists_url":"https://api.github.com/users/ola357/gists{/gist_id}","starred_url":"https://api.github.com/users/ola357/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ola357/subscriptions","organizations_url":"https://api.github.com/users/ola357/orgs","repos_url":"https://api.github.com/users/ola357/repos","events_url":"https://api.github.com/users/ola357/events{/privacy}","received_events_url":"https://api.github.com/users/ola357/received_events","type":"User","site_admin":false},{"login":"OlawaleJoseph","id":46751363,"node_id":"MDQ6VXNlcjQ2NzUxMzYz","avatar_url":"https://avatars0.githubusercontent.com/u/46751363?v=4","gravatar_id":"","url":"https://api.github.com/users/OlawaleJoseph","html_url":"https://github.com/OlawaleJoseph","followers_url":"https://api.github.com/users/OlawaleJoseph/followers","following_url":"https://api.github.com/users/OlawaleJoseph/following{/other_user}","gists_url":"https://api.github.com/users/OlawaleJoseph/gists{/gist_id}","starred_url":"https://api.github.com/users/OlawaleJoseph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OlawaleJoseph/subscriptions","organizations_url":"https://api.github.com/users/OlawaleJoseph/orgs","repos_url":"https://api.github.com/users/OlawaleJoseph/repos","events_url":"https://api.github.com/users/OlawaleJoseph/events{/privacy}","received_events_url":"https://api.github.com/users/OlawaleJoseph/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1503660908,"node_id":"MDU6TGFiZWwxNTAzNjYwOTA4","url":"https://api.github.com/repos/andela/firestar-backend/labels/peer%20Review","name":"peer Review","color":"CCCC00","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/andela/firestar-backend/pulls/25/commits","review_comments_url":"https://api.github.com/repos/andela/firestar-backend/pulls/25/comments","review_comment_url":"https://api.github.com/repos/andela/firestar-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/firestar-backend/issues/25/comments","statuses_url":"https://api.github.com/repos/andela/firestar-backend/statuses/e271d26573ef792fe31da9b63d498a6edac4769d","head":{"label":"andela:ft-reset-password-167730744","ref":"ft-reset-password-167730744","sha":"e271d26573ef792fe31da9b63d498a6edac4769d","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":200845849,"node_id":"MDEwOlJlcG9zaXRvcnkyMDA4NDU4NDk=","name":"firestar-backend","full_name":"andela/firestar-backend","private":false,"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},"html_url":"https://github.com/andela/firestar-backend","description":null,"fork":false,"url":"https://api.github.com/repos/andela/firestar-backend","forks_url":"https://api.github.com/repos/andela/firestar-backend/forks","keys_url":"https://api.github.com/repos/andela/firestar-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/firestar-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/firestar-backend/teams","hooks_url":"https://api.github.com/repos/andela/firestar-backend/hooks","issue_events_url":"https://api.github.com/repos/andela/firestar-backend/issues/events{/number}","events_url":"https://api.github.com/repos/andela/firestar-backend/events","assignees_url":"https://api.github.com/repos/andela/firestar-backend/assignees{/user}","branches_url":"https://api.github.com/repos/andela/firestar-backend/branches{/branch}","tags_url":"https://api.github.com/repos/andela/firestar-backend/tags","blobs_url":"https://api.github.com/repos/andela/firestar-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/firestar-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/firestar-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/firestar-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/firestar-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/firestar-backend/languages","stargazers_url":"https://api.github.com/repos/andela/firestar-backend/stargazers","contributors_url":"https://api.github.com/repos/andela/firestar-backend/contributors","subscribers_url":"https://api.github.com/repos/andela/firestar-backend/subscribers","subscription_url":"https://api.github.com/repos/andela/firestar-backend/subscription","commits_url":"https://api.github.com/repos/andela/firestar-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/firestar-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/firestar-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/firestar-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/firestar-backend/contents/{+path}","compare_url":"https://api.github.com/repos/andela/firestar-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/firestar-backend/merges","archive_url":"https://api.github.com/repos/andela/firestar-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/firestar-backend/downloads","issues_url":"https://api.github.com/repos/andela/firestar-backend/issues{/number}","pulls_url":"https://api.github.com/repos/andela/firestar-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/firestar-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/firestar-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/firestar-backend/labels{/name}","releases_url":"https://api.github.com/repos/andela/firestar-backend/releases{/id}","deployments_url":"https://api.github.com/repos/andela/firestar-backend/deployments","created_at":"2019-08-06T12:21:19Z","updated_at":"2019-08-22T11:42:42Z","pushed_at":"2019-08-26T09:08:05Z","git_url":"git://github.com/andela/firestar-backend.git","ssh_url":"git@github.com:andela/firestar-backend.git","clone_url":"https://github.com/andela/firestar-backend.git","svn_url":"https://github.com/andela/firestar-backend","homepage":null,"size":320,"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":1,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":null,"forks":1,"open_issues":2,"watchers":0,"default_branch":"stage"}},"base":{"label":"andela:stage","ref":"stage","sha":"9c336f99f17e84895c0252b7b009b2712d303689","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":200845849,"node_id":"MDEwOlJlcG9zaXRvcnkyMDA4NDU4NDk=","name":"firestar-backend","full_name":"andela/firestar-backend","private":false,"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},"html_url":"https://github.com/andela/firestar-backend","description":null,"fork":false,"url":"https://api.github.com/repos/andela/firestar-backend","forks_url":"https://api.github.com/repos/andela/firestar-backend/forks","keys_url":"https://api.github.com/repos/andela/firestar-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/firestar-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/firestar-backend/teams","hooks_url":"https://api.github.com/repos/andela/firestar-backend/hooks","issue_events_url":"https://api.github.com/repos/andela/firestar-backend/issues/events{/number}","events_url":"https://api.github.com/repos/andela/firestar-backend/events","assignees_url":"https://api.github.com/repos/andela/firestar-backend/assignees{/user}","branches_url":"https://api.github.com/repos/andela/firestar-backend/branches{/branch}","tags_url":"https://api.github.com/repos/andela/firestar-backend/tags","blobs_url":"https://api.github.com/repos/andela/firestar-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/firestar-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/firestar-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/firestar-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/firestar-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/firestar-backend/languages","stargazers_url":"https://api.github.com/repos/andela/firestar-backend/stargazers","contributors_url":"https://api.github.com/repos/andela/firestar-backend/contributors","subscribers_url":"https://api.github.com/repos/andela/firestar-backend/subscribers","subscription_url":"https://api.github.com/repos/andela/firestar-backend/subscription","commits_url":"https://api.github.com/repos/andela/firestar-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/firestar-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/firestar-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/firestar-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/firestar-backend/contents/{+path}","compare_url":"https://api.github.com/repos/andela/firestar-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/firestar-backend/merges","archive_url":"https://api.github.com/repos/andela/firestar-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/firestar-backend/downloads","issues_url":"https://api.github.com/repos/andela/firestar-backend/issues{/number}","pulls_url":"https://api.github.com/repos/andela/firestar-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/firestar-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/firestar-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/firestar-backend/labels{/name}","releases_url":"https://api.github.com/repos/andela/firestar-backend/releases{/id}","deployments_url":"https://api.github.com/repos/andela/firestar-backend/deployments","created_at":"2019-08-06T12:21:19Z","updated_at":"2019-08-22T11:42:42Z","pushed_at":"2019-08-26T09:08:05Z","git_url":"git://github.com/andela/firestar-backend.git","ssh_url":"git@github.com:andela/firestar-backend.git","clone_url":"https://github.com/andela/firestar-backend.git","svn_url":"https://github.com/andela/firestar-backend","homepage":null,"size":320,"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":1,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":2,"license":null,"forks":1,"open_issues":2,"watchers":0,"default_branch":"stage"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/firestar-backend/pulls/25"},"html":{"href":"https://github.com/andela/firestar-backend/pull/25"},"issue":{"href":"https://api.github.com/repos/andela/firestar-backend/issues/25"},"comments":{"href":"https://api.github.com/repos/andela/firestar-backend/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/firestar-backend/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/firestar-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/firestar-backend/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/andela/firestar-backend/statuses/e271d26573ef792fe31da9b63d498a6edac4769d"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"rovilay"}}