{"action":"created","comment":{"url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/comments/189452146","pull_request_review_id":121636820,"id":189452146,"diff_hunk":"@@ -1,34 +1,50 @@\n+const User  = require('../../models/user');\n const { Router }    = require('express');\n-\n+const passport     = require('passport');\n+const bcrypt = require('bcrypt');\n \n const router = new Router();\n module.exports = router;\n \n+router.post('/signin', async function(req, res) {\n+  const { email, password } = req.body;\n \n-router.get('/signin', async function(req, res) {\n+  const result = await User.findPass({email, password});","path":"routes/app/signin.js","position":14,"original_position":14,"commit_id":"39cadcfcbbc7f11e44f91166db5af16d49aea914","original_commit_id":"b0726a596eb712337a035cee0c52b8e7634238ea","user":{"login":"tylerbmcsilva","id":2246200,"avatar_url":"https://avatars1.githubusercontent.com/u/2246200?v=4","gravatar_id":"","url":"https://api.github.com/users/tylerbmcsilva","html_url":"https://github.com/tylerbmcsilva","followers_url":"https://api.github.com/users/tylerbmcsilva/followers","following_url":"https://api.github.com/users/tylerbmcsilva/following{/other_user}","gists_url":"https://api.github.com/users/tylerbmcsilva/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerbmcsilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerbmcsilva/subscriptions","organizations_url":"https://api.github.com/users/tylerbmcsilva/orgs","repos_url":"https://api.github.com/users/tylerbmcsilva/repos","events_url":"https://api.github.com/users/tylerbmcsilva/events{/privacy}","received_events_url":"https://api.github.com/users/tylerbmcsilva/received_events","type":"User","site_admin":false},"body":"Oh okay then just have it be:\r\n```\r\nconst result = ...\r\nif(result.length === 0) throw new Error('User does not exist');\r\nconst user = result[0];\r\nconst hash = result[0].password;\r\n```","created_at":"2018-05-20T06:08:20Z","updated_at":"2018-05-20T06:08:20Z","html_url":"https://github.com/tylerbmcsilva/pictor-encryption/pull/75#discussion_r189452146","pull_request_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/comments/189452146"},"html":{"href":"https://github.com/tylerbmcsilva/pictor-encryption/pull/75#discussion_r189452146"},"pull_request":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75"}},"in_reply_to_id":189451962},"pull_request":{"url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75","id":189213485,"html_url":"https://github.com/tylerbmcsilva/pictor-encryption/pull/75","diff_url":"https://github.com/tylerbmcsilva/pictor-encryption/pull/75.diff","patch_url":"https://github.com/tylerbmcsilva/pictor-encryption/pull/75.patch","issue_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/75","number":75,"state":"open","locked":false,"title":"Reg login logout","user":{"login":"yungRoz","id":25485714,"avatar_url":"https://avatars0.githubusercontent.com/u/25485714?v=4","gravatar_id":"","url":"https://api.github.com/users/yungRoz","html_url":"https://github.com/yungRoz","followers_url":"https://api.github.com/users/yungRoz/followers","following_url":"https://api.github.com/users/yungRoz/following{/other_user}","gists_url":"https://api.github.com/users/yungRoz/gists{/gist_id}","starred_url":"https://api.github.com/users/yungRoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yungRoz/subscriptions","organizations_url":"https://api.github.com/users/yungRoz/orgs","repos_url":"https://api.github.com/users/yungRoz/repos","events_url":"https://api.github.com/users/yungRoz/events{/privacy}","received_events_url":"https://api.github.com/users/yungRoz/received_events","type":"User","site_admin":false},"body":"When user registers: \r\n\r\n- post request is sent to /user/new with user data where: \r\n   - password is hashed\r\n   - user data is stored in database\r\n   - user is logged in via passport \r\n   - express-mysql-session is used to store session data \r\n  - authentication is checked via middleware authUser()\r\n\r\nIf you want to authenticate before showing a page, just include passport and the middleware authUser before the callback function. For example, see app rendering of feed. Feed is only displayed if user is logged in via passport. \r\n\r\nWhen user signs in: \r\n\r\n- post request is sent to /signin with email and password: \r\n  - user searched for in database\r\n  - password is checked against hash with bcrypt\r\n  - if passwords don't match or user is not found, homepage is rendered, else /feed is rendered\r\n\r\nWhen user logs out: \r\n- get request is sent to /logout (right now this is in home.js route, may want to move)\r\n  - user is logged out via passport\r\n  - session cookie data is destroyed\r\n  - user is redirected to homepage\r\n\r\n\r\nNote: \r\nA new file under models for sessions has been added. It must have options set to the same as the database. Also currently the sessions secret is displayed and will need to be removed. ","created_at":"2018-05-20T00:50:39Z","updated_at":"2018-05-20T06:08:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"847640e0694422b6334da4f3eaeac10fea9c1ce1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75/commits","review_comments_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75/comments","review_comment_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/75/comments","statuses_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/statuses/39cadcfcbbc7f11e44f91166db5af16d49aea914","head":{"label":"tylerbmcsilva:reg-login-logout","ref":"reg-login-logout","sha":"39cadcfcbbc7f11e44f91166db5af16d49aea914","user":{"login":"tylerbmcsilva","id":2246200,"avatar_url":"https://avatars1.githubusercontent.com/u/2246200?v=4","gravatar_id":"","url":"https://api.github.com/users/tylerbmcsilva","html_url":"https://github.com/tylerbmcsilva","followers_url":"https://api.github.com/users/tylerbmcsilva/followers","following_url":"https://api.github.com/users/tylerbmcsilva/following{/other_user}","gists_url":"https://api.github.com/users/tylerbmcsilva/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerbmcsilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerbmcsilva/subscriptions","organizations_url":"https://api.github.com/users/tylerbmcsilva/orgs","repos_url":"https://api.github.com/users/tylerbmcsilva/repos","events_url":"https://api.github.com/users/tylerbmcsilva/events{/privacy}","received_events_url":"https://api.github.com/users/tylerbmcsilva/received_events","type":"User","site_admin":false},"repo":{"id":129188318,"name":"pictor-encryption","full_name":"tylerbmcsilva/pictor-encryption","owner":{"login":"tylerbmcsilva","id":2246200,"avatar_url":"https://avatars1.githubusercontent.com/u/2246200?v=4","gravatar_id":"","url":"https://api.github.com/users/tylerbmcsilva","html_url":"https://github.com/tylerbmcsilva","followers_url":"https://api.github.com/users/tylerbmcsilva/followers","following_url":"https://api.github.com/users/tylerbmcsilva/following{/other_user}","gists_url":"https://api.github.com/users/tylerbmcsilva/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerbmcsilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerbmcsilva/subscriptions","organizations_url":"https://api.github.com/users/tylerbmcsilva/orgs","repos_url":"https://api.github.com/users/tylerbmcsilva/repos","events_url":"https://api.github.com/users/tylerbmcsilva/events{/privacy}","received_events_url":"https://api.github.com/users/tylerbmcsilva/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tylerbmcsilva/pictor-encryption","description":null,"fork":false,"url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption","forks_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/forks","keys_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/teams","hooks_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/hooks","issue_events_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/events{/number}","events_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/events","assignees_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/assignees{/user}","branches_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/branches{/branch}","tags_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/tags","blobs_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/refs{/sha}","trees_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/statuses/{sha}","languages_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/languages","stargazers_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/stargazers","contributors_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/contributors","subscribers_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/subscribers","subscription_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/subscription","commits_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/commits{/sha}","git_commits_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/commits{/sha}","comments_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/comments{/number}","issue_comment_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/comments{/number}","contents_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/contents/{+path}","compare_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/merges","archive_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/downloads","issues_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues{/number}","pulls_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls{/number}","milestones_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/milestones{/number}","notifications_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/labels{/name}","releases_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/releases{/id}","deployments_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/deployments","created_at":"2018-04-12T03:36:28Z","updated_at":"2018-05-20T02:21:01Z","pushed_at":"2018-05-20T05:56:57Z","git_url":"git://github.com/tylerbmcsilva/pictor-encryption.git","ssh_url":"git@github.com:tylerbmcsilva/pictor-encryption.git","clone_url":"https://github.com/tylerbmcsilva/pictor-encryption.git","svn_url":"https://github.com/tylerbmcsilva/pictor-encryption","homepage":null,"size":1048,"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":25,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":25,"watchers":0,"default_branch":"master"}},"base":{"label":"tylerbmcsilva:master","ref":"master","sha":"41bf3e5b1d969f2e9841c471715d33201d20d6d6","user":{"login":"tylerbmcsilva","id":2246200,"avatar_url":"https://avatars1.githubusercontent.com/u/2246200?v=4","gravatar_id":"","url":"https://api.github.com/users/tylerbmcsilva","html_url":"https://github.com/tylerbmcsilva","followers_url":"https://api.github.com/users/tylerbmcsilva/followers","following_url":"https://api.github.com/users/tylerbmcsilva/following{/other_user}","gists_url":"https://api.github.com/users/tylerbmcsilva/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerbmcsilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerbmcsilva/subscriptions","organizations_url":"https://api.github.com/users/tylerbmcsilva/orgs","repos_url":"https://api.github.com/users/tylerbmcsilva/repos","events_url":"https://api.github.com/users/tylerbmcsilva/events{/privacy}","received_events_url":"https://api.github.com/users/tylerbmcsilva/received_events","type":"User","site_admin":false},"repo":{"id":129188318,"name":"pictor-encryption","full_name":"tylerbmcsilva/pictor-encryption","owner":{"login":"tylerbmcsilva","id":2246200,"avatar_url":"https://avatars1.githubusercontent.com/u/2246200?v=4","gravatar_id":"","url":"https://api.github.com/users/tylerbmcsilva","html_url":"https://github.com/tylerbmcsilva","followers_url":"https://api.github.com/users/tylerbmcsilva/followers","following_url":"https://api.github.com/users/tylerbmcsilva/following{/other_user}","gists_url":"https://api.github.com/users/tylerbmcsilva/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerbmcsilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerbmcsilva/subscriptions","organizations_url":"https://api.github.com/users/tylerbmcsilva/orgs","repos_url":"https://api.github.com/users/tylerbmcsilva/repos","events_url":"https://api.github.com/users/tylerbmcsilva/events{/privacy}","received_events_url":"https://api.github.com/users/tylerbmcsilva/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tylerbmcsilva/pictor-encryption","description":null,"fork":false,"url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption","forks_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/forks","keys_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/teams","hooks_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/hooks","issue_events_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/events{/number}","events_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/events","assignees_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/assignees{/user}","branches_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/branches{/branch}","tags_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/tags","blobs_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/refs{/sha}","trees_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/statuses/{sha}","languages_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/languages","stargazers_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/stargazers","contributors_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/contributors","subscribers_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/subscribers","subscription_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/subscription","commits_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/commits{/sha}","git_commits_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/git/commits{/sha}","comments_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/comments{/number}","issue_comment_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/comments{/number}","contents_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/contents/{+path}","compare_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/merges","archive_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/downloads","issues_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues{/number}","pulls_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls{/number}","milestones_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/milestones{/number}","notifications_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/labels{/name}","releases_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/releases{/id}","deployments_url":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/deployments","created_at":"2018-04-12T03:36:28Z","updated_at":"2018-05-20T02:21:01Z","pushed_at":"2018-05-20T05:56:57Z","git_url":"git://github.com/tylerbmcsilva/pictor-encryption.git","ssh_url":"git@github.com:tylerbmcsilva/pictor-encryption.git","clone_url":"https://github.com/tylerbmcsilva/pictor-encryption.git","svn_url":"https://github.com/tylerbmcsilva/pictor-encryption","homepage":null,"size":1048,"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":25,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0"},"forks":0,"open_issues":25,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75"},"html":{"href":"https://github.com/tylerbmcsilva/pictor-encryption/pull/75"},"issue":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/75"},"comments":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/issues/75/comments"},"review_comments":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75/comments"},"review_comment":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/pulls/75/commits"},"statuses":{"href":"https://api.github.com/repos/tylerbmcsilva/pictor-encryption/statuses/39cadcfcbbc7f11e44f91166db5af16d49aea914"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"tylerbmcsilva"}}