{"action":"created","comment":{"url":"https://api.github.com/repos/HackIllinois/api-2017/pulls/comments/73280572","id":73280572,"diff_hunk":"@@ -65,3 +68,48 @@ module.exports.verify = function(token) {\n \t\t\tthrow new errors.UnprocessableRequestError(message);\n \t\t});\n };\n+\n+\n+/**\n+ * Generates a token and deletes all existing tokens\n+ * with the same scope.\n+ * @param {User} user The user object to create a reset token for.\n+ * @param {String} scope The scope to create the token for.\n+ * @return {Promise<Bool>} Returns a Promise that resolves to\n+ *                         true on a successful token creation.\n+ */\n+module.exports.generateToken = function(user, scope){","path":"api/v1/services/AuthService.js","position":29,"original_position":29,"commit_id":"70bb7663a809e76924a3dd401711f2a158a01bde","original_commit_id":"70bb7663a809e76924a3dd401711f2a158a01bde","user":{"login":"nmagerko","id":3152067,"avatar_url":"https://avatars.githubusercontent.com/u/3152067?v=3","gravatar_id":"","url":"https://api.github.com/users/nmagerko","html_url":"https://github.com/nmagerko","followers_url":"https://api.github.com/users/nmagerko/followers","following_url":"https://api.github.com/users/nmagerko/following{/other_user}","gists_url":"https://api.github.com/users/nmagerko/gists{/gist_id}","starred_url":"https://api.github.com/users/nmagerko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmagerko/subscriptions","organizations_url":"https://api.github.com/users/nmagerko/orgs","repos_url":"https://api.github.com/users/nmagerko/repos","events_url":"https://api.github.com/users/nmagerko/events{/privacy}","received_events_url":"https://api.github.com/users/nmagerko/received_events","type":"User","site_admin":false},"body":"This looks like it would be great in a `TokenService`","created_at":"2016-08-03T04:52:32Z","updated_at":"2016-08-03T04:52:32Z","html_url":"https://github.com/HackIllinois/api-2017/pull/17#discussion_r73280572","pull_request_url":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/HackIllinois/api-2017/pulls/comments/73280572"},"html":{"href":"https://github.com/HackIllinois/api-2017/pull/17#discussion_r73280572"},"pull_request":{"href":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17","id":79828215,"html_url":"https://github.com/HackIllinois/api-2017/pull/17","diff_url":"https://github.com/HackIllinois/api-2017/pull/17.diff","patch_url":"https://github.com/HackIllinois/api-2017/pull/17.patch","issue_url":"https://api.github.com/repos/HackIllinois/api-2017/issues/17","number":17,"state":"open","locked":false,"title":"Feature/password reset","user":{"login":"shotaroikeda","id":9062304,"avatar_url":"https://avatars.githubusercontent.com/u/9062304?v=3","gravatar_id":"","url":"https://api.github.com/users/shotaroikeda","html_url":"https://github.com/shotaroikeda","followers_url":"https://api.github.com/users/shotaroikeda/followers","following_url":"https://api.github.com/users/shotaroikeda/following{/other_user}","gists_url":"https://api.github.com/users/shotaroikeda/gists{/gist_id}","starred_url":"https://api.github.com/users/shotaroikeda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shotaroikeda/subscriptions","organizations_url":"https://api.github.com/users/shotaroikeda/orgs","repos_url":"https://api.github.com/users/shotaroikeda/repos","events_url":"https://api.github.com/users/shotaroikeda/events{/privacy}","received_events_url":"https://api.github.com/users/shotaroikeda/received_events","type":"User","site_admin":false},"body":"@tommypacker and I have added the password resetting feature, including a generic use Token that can be used in the future for things such as giving others API access to our service.\r\n\r\nThings Done:\r\n\r\n- [x] Created Password Reset endpoints, as well as sending the user a link which will reset their token (exact link TBD due to web), via GET/POST request at `/v1/auth/reset`. \r\n- [x] Documented and updated the [wiki for the auth endpoint](https://github.com/HackIllinois/api-2017/wiki/Auth-Documentation)\r\n- [x] Created the database model for Tokens with expirations.\r\n\r\nSome issues:\r\n- [ ] It seems as though the middleware is not working. Sending a POST request to `/v1/auth/reset` with a password length of less than 8 seems to work. This should throw an error instead.\r\n\r\nReproduction:\r\n\r\n1. Create a user (in this example I used test@user.com)\r\n2. Send a GET request to `/v1/auth/reset` with an email parameter. Example: `curl localhost:8080/v1/auth/reset?email=test@user.com`\r\n3. The console should log a token for you. Use this token as the token parameter for the next POST request (in the example I will use `0.q84lebgld7rmamgsi3ihmdnc0arhhnc` as the token)\r\n4. Send a POST request to `/v1/auth/reset` with the payload specified in the wiki. Make sure you have a password with a length of less than 8. Example: `curl -X POST -H \"Content-Type: application/json\" -d '{\"email\": \"test@user.com\", \"password\": \"a\", \"token\": \"0.q84lebgld7rmamgsi3ihmdnc0arhhnc\"}' localhost:8080/v1/auth/reset`\r\n5. The returned token is valid authentication token, instead of an error.\r\n","created_at":"2016-08-02T23:50:52Z","updated_at":"2016-08-03T04:52:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6661bd95acea4dff3aeb71dfd50fe8c7778dd4a2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17/commits","review_comments_url":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17/comments","review_comment_url":"https://api.github.com/repos/HackIllinois/api-2017/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HackIllinois/api-2017/issues/17/comments","statuses_url":"https://api.github.com/repos/HackIllinois/api-2017/statuses/70bb7663a809e76924a3dd401711f2a158a01bde","head":{"label":"HackIllinois:feature/password-reset","ref":"feature/password-reset","sha":"70bb7663a809e76924a3dd401711f2a158a01bde","user":{"login":"HackIllinois","id":5751098,"avatar_url":"https://avatars.githubusercontent.com/u/5751098?v=3","gravatar_id":"","url":"https://api.github.com/users/HackIllinois","html_url":"https://github.com/HackIllinois","followers_url":"https://api.github.com/users/HackIllinois/followers","following_url":"https://api.github.com/users/HackIllinois/following{/other_user}","gists_url":"https://api.github.com/users/HackIllinois/gists{/gist_id}","starred_url":"https://api.github.com/users/HackIllinois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackIllinois/subscriptions","organizations_url":"https://api.github.com/users/HackIllinois/orgs","repos_url":"https://api.github.com/users/HackIllinois/repos","events_url":"https://api.github.com/users/HackIllinois/events{/privacy}","received_events_url":"https://api.github.com/users/HackIllinois/received_events","type":"Organization","site_admin":false},"repo":{"id":60983966,"name":"api-2017","full_name":"HackIllinois/api-2017","owner":{"login":"HackIllinois","id":5751098,"avatar_url":"https://avatars.githubusercontent.com/u/5751098?v=3","gravatar_id":"","url":"https://api.github.com/users/HackIllinois","html_url":"https://github.com/HackIllinois","followers_url":"https://api.github.com/users/HackIllinois/followers","following_url":"https://api.github.com/users/HackIllinois/following{/other_user}","gists_url":"https://api.github.com/users/HackIllinois/gists{/gist_id}","starred_url":"https://api.github.com/users/HackIllinois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackIllinois/subscriptions","organizations_url":"https://api.github.com/users/HackIllinois/orgs","repos_url":"https://api.github.com/users/HackIllinois/repos","events_url":"https://api.github.com/users/HackIllinois/events{/privacy}","received_events_url":"https://api.github.com/users/HackIllinois/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HackIllinois/api-2017","description":"The back-end services supporting HackIllinois 2017","fork":false,"url":"https://api.github.com/repos/HackIllinois/api-2017","forks_url":"https://api.github.com/repos/HackIllinois/api-2017/forks","keys_url":"https://api.github.com/repos/HackIllinois/api-2017/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HackIllinois/api-2017/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HackIllinois/api-2017/teams","hooks_url":"https://api.github.com/repos/HackIllinois/api-2017/hooks","issue_events_url":"https://api.github.com/repos/HackIllinois/api-2017/issues/events{/number}","events_url":"https://api.github.com/repos/HackIllinois/api-2017/events","assignees_url":"https://api.github.com/repos/HackIllinois/api-2017/assignees{/user}","branches_url":"https://api.github.com/repos/HackIllinois/api-2017/branches{/branch}","tags_url":"https://api.github.com/repos/HackIllinois/api-2017/tags","blobs_url":"https://api.github.com/repos/HackIllinois/api-2017/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HackIllinois/api-2017/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HackIllinois/api-2017/git/refs{/sha}","trees_url":"https://api.github.com/repos/HackIllinois/api-2017/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HackIllinois/api-2017/statuses/{sha}","languages_url":"https://api.github.com/repos/HackIllinois/api-2017/languages","stargazers_url":"https://api.github.com/repos/HackIllinois/api-2017/stargazers","contributors_url":"https://api.github.com/repos/HackIllinois/api-2017/contributors","subscribers_url":"https://api.github.com/repos/HackIllinois/api-2017/subscribers","subscription_url":"https://api.github.com/repos/HackIllinois/api-2017/subscription","commits_url":"https://api.github.com/repos/HackIllinois/api-2017/commits{/sha}","git_commits_url":"https://api.github.com/repos/HackIllinois/api-2017/git/commits{/sha}","comments_url":"https://api.github.com/repos/HackIllinois/api-2017/comments{/number}","issue_comment_url":"https://api.github.com/repos/HackIllinois/api-2017/issues/comments{/number}","contents_url":"https://api.github.com/repos/HackIllinois/api-2017/contents/{+path}","compare_url":"https://api.github.com/repos/HackIllinois/api-2017/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HackIllinois/api-2017/merges","archive_url":"https://api.github.com/repos/HackIllinois/api-2017/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HackIllinois/api-2017/downloads","issues_url":"https://api.github.com/repos/HackIllinois/api-2017/issues{/number}","pulls_url":"https://api.github.com/repos/HackIllinois/api-2017/pulls{/number}","milestones_url":"https://api.github.com/repos/HackIllinois/api-2017/milestones{/number}","notifications_url":"https://api.github.com/repos/HackIllinois/api-2017/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HackIllinois/api-2017/labels{/name}","releases_url":"https://api.github.com/repos/HackIllinois/api-2017/releases{/id}","deployments_url":"https://api.github.com/repos/HackIllinois/api-2017/deployments","created_at":"2016-06-12T18:54:33Z","updated_at":"2016-07-18T16:25:44Z","pushed_at":"2016-08-03T04:15:51Z","git_url":"git://github.com/HackIllinois/api-2017.git","ssh_url":"git@github.com:HackIllinois/api-2017.git","clone_url":"https://github.com/HackIllinois/api-2017.git","svn_url":"https://github.com/HackIllinois/api-2017","homepage":"","size":146,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":0,"default_branch":"master"}},"base":{"label":"HackIllinois:staging","ref":"staging","sha":"584b3b659422309932d5915c227d86f94772e47f","user":{"login":"HackIllinois","id":5751098,"avatar_url":"https://avatars.githubusercontent.com/u/5751098?v=3","gravatar_id":"","url":"https://api.github.com/users/HackIllinois","html_url":"https://github.com/HackIllinois","followers_url":"https://api.github.com/users/HackIllinois/followers","following_url":"https://api.github.com/users/HackIllinois/following{/other_user}","gists_url":"https://api.github.com/users/HackIllinois/gists{/gist_id}","starred_url":"https://api.github.com/users/HackIllinois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackIllinois/subscriptions","organizations_url":"https://api.github.com/users/HackIllinois/orgs","repos_url":"https://api.github.com/users/HackIllinois/repos","events_url":"https://api.github.com/users/HackIllinois/events{/privacy}","received_events_url":"https://api.github.com/users/HackIllinois/received_events","type":"Organization","site_admin":false},"repo":{"id":60983966,"name":"api-2017","full_name":"HackIllinois/api-2017","owner":{"login":"HackIllinois","id":5751098,"avatar_url":"https://avatars.githubusercontent.com/u/5751098?v=3","gravatar_id":"","url":"https://api.github.com/users/HackIllinois","html_url":"https://github.com/HackIllinois","followers_url":"https://api.github.com/users/HackIllinois/followers","following_url":"https://api.github.com/users/HackIllinois/following{/other_user}","gists_url":"https://api.github.com/users/HackIllinois/gists{/gist_id}","starred_url":"https://api.github.com/users/HackIllinois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackIllinois/subscriptions","organizations_url":"https://api.github.com/users/HackIllinois/orgs","repos_url":"https://api.github.com/users/HackIllinois/repos","events_url":"https://api.github.com/users/HackIllinois/events{/privacy}","received_events_url":"https://api.github.com/users/HackIllinois/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/HackIllinois/api-2017","description":"The back-end services supporting HackIllinois 2017","fork":false,"url":"https://api.github.com/repos/HackIllinois/api-2017","forks_url":"https://api.github.com/repos/HackIllinois/api-2017/forks","keys_url":"https://api.github.com/repos/HackIllinois/api-2017/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HackIllinois/api-2017/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HackIllinois/api-2017/teams","hooks_url":"https://api.github.com/repos/HackIllinois/api-2017/hooks","issue_events_url":"https://api.github.com/repos/HackIllinois/api-2017/issues/events{/number}","events_url":"https://api.github.com/repos/HackIllinois/api-2017/events","assignees_url":"https://api.github.com/repos/HackIllinois/api-2017/assignees{/user}","branches_url":"https://api.github.com/repos/HackIllinois/api-2017/branches{/branch}","tags_url":"https://api.github.com/repos/HackIllinois/api-2017/tags","blobs_url":"https://api.github.com/repos/HackIllinois/api-2017/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HackIllinois/api-2017/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HackIllinois/api-2017/git/refs{/sha}","trees_url":"https://api.github.com/repos/HackIllinois/api-2017/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HackIllinois/api-2017/statuses/{sha}","languages_url":"https://api.github.com/repos/HackIllinois/api-2017/languages","stargazers_url":"https://api.github.com/repos/HackIllinois/api-2017/stargazers","contributors_url":"https://api.github.com/repos/HackIllinois/api-2017/contributors","subscribers_url":"https://api.github.com/repos/HackIllinois/api-2017/subscribers","subscription_url":"https://api.github.com/repos/HackIllinois/api-2017/subscription","commits_url":"https://api.github.com/repos/HackIllinois/api-2017/commits{/sha}","git_commits_url":"https://api.github.com/repos/HackIllinois/api-2017/git/commits{/sha}","comments_url":"https://api.github.com/repos/HackIllinois/api-2017/comments{/number}","issue_comment_url":"https://api.github.com/repos/HackIllinois/api-2017/issues/comments{/number}","contents_url":"https://api.github.com/repos/HackIllinois/api-2017/contents/{+path}","compare_url":"https://api.github.com/repos/HackIllinois/api-2017/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HackIllinois/api-2017/merges","archive_url":"https://api.github.com/repos/HackIllinois/api-2017/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HackIllinois/api-2017/downloads","issues_url":"https://api.github.com/repos/HackIllinois/api-2017/issues{/number}","pulls_url":"https://api.github.com/repos/HackIllinois/api-2017/pulls{/number}","milestones_url":"https://api.github.com/repos/HackIllinois/api-2017/milestones{/number}","notifications_url":"https://api.github.com/repos/HackIllinois/api-2017/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HackIllinois/api-2017/labels{/name}","releases_url":"https://api.github.com/repos/HackIllinois/api-2017/releases{/id}","deployments_url":"https://api.github.com/repos/HackIllinois/api-2017/deployments","created_at":"2016-06-12T18:54:33Z","updated_at":"2016-07-18T16:25:44Z","pushed_at":"2016-08-03T04:15:51Z","git_url":"git://github.com/HackIllinois/api-2017.git","ssh_url":"git@github.com:HackIllinois/api-2017.git","clone_url":"https://github.com/HackIllinois/api-2017.git","svn_url":"https://github.com/HackIllinois/api-2017","homepage":"","size":146,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":11,"forks":1,"open_issues":11,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17"},"html":{"href":"https://github.com/HackIllinois/api-2017/pull/17"},"issue":{"href":"https://api.github.com/repos/HackIllinois/api-2017/issues/17"},"comments":{"href":"https://api.github.com/repos/HackIllinois/api-2017/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/HackIllinois/api-2017/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HackIllinois/api-2017/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/HackIllinois/api-2017/statuses/70bb7663a809e76924a3dd401711f2a158a01bde"}}}}
{"actor":{"display_login":"nmagerko"}}