{"action":"created","comment":{"url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/comments/134099529","pull_request_review_id":57357398,"id":134099529,"diff_hunk":"@@ -0,0 +1,121 @@\n+import bcrypt from 'bcrypt';\n+import jwt from 'jsonwebtoken';\n+import {\n+  UserDetails,\n+  Memberships,\n+} from '../models';\n+\n+// email validation here\n+const emailRegex = /^(([^<>()[\\].,;:\\s@\"]+(\\.[^<>()[\\].,;:\\s@\"]+)*)|(\".+\"))@(([^<>()[\\].,;:\\s@\"]+\\.)+[^<>()[\\].,;:\\s@\"]{2,})$/i;\n+const validateEmail = emailAddress =>\n+  emailRegex.test(emailAddress); // returns true or false\n+\n+class userLoginDetails {\n+\n+  static validateSignup(username,\n+    password,\n+    lastname,\n+    firstname,\n+    email,\n+  ) {\n+    if (username === null) {\n+      return 'Username Invalid';\n+    } else if (password === null) {\n+      return 'Password Invalid';\n+    } else if (email === null) {\n+      return 'Email Address Invalid';\n+    } else if (firstname === null) {\n+      return 'First Name Invalid';\n+    } else if (lastname === null) {\n+      return 'Last Name Invalid';\n+    } else if (!validateEmail(email)) {\n+      return 'Email Address is invalid';\n+    } else if (username.length < 2) {\n+      return 'Username too short';\n+    } else if (password.length < 6) {\n+      return 'Password too short';\n+    } else if (lastname.length < 2) {\n+      return 'Last Name too short';\n+    } else if (firstname.length < 2) {\n+      return 'First Name too short';\n+    }\n+    return 0;\n+  }\n+  // for sign up\n+  static signup(req, res) {\n+    // declare variables\n+    const password = req.body.password || null;\n+    const lastName = req.body.lastname || null;\n+    const firstName = req.body.firstname || null;\n+    const email = req.body.email || null;\n+    const phone = req.body.phone || null;\n+    const userName = req.body.username || null;\n+\n+    const errOrValid = userLoginDetails.validateSignup(userName,\n+      password, lastName, firstName, email,\n+    );\n+    if (errOrValid !== 0) { // if unvalidated information\n+      res.status(400).json({\n+        status: 'unsuccessful',\n+        error: errOrValid,\n+      });\n+    } else {\n+      bcrypt\n+        .hash(password, 8)\n+        .then((hash) => {\n+          // using hashed password (hash)\n+          if (!hash) {\n+            res.status(400).json({\n+              status: 'unsuccessful',\n+            });\n+          } else {\n+            UserDetails\n+              .create({\n+                firstname: firstName,\n+                lastname: lastName,\n+                emailaddress: email.toLowerCase(),\n+                phonenumber: phone,\n+                username: userName.toLowerCase(),\n+                password: hash,\n+              })\n+              .then(userSignup =>\n+                Memberships\n+                .findById(1)\n+                .then(setMembershipDetails =>\n+                  userSignup.setMembership(setMembershipDetails),\n+                )\n+                .then((signupData) => {\n+                  // Add user info to token\n+                  const tokenInfo = {\n+                    username: signupData.dataValues.username,\n+                    userId: signupData.dataValues.id,\n+                    email: signupData.dataValues.emailaddress,\n+                  };\n+                  const signupToken = jwt.sign(tokenInfo,\n+                    req.app.get('JsonSecret'), {\n+                      expiresIn: 1440 * 60, // 24 hours\n+                    }); // for verification things\n+                  res.status(202).json({\n+                    status: 'success',\n+                    message: 'User account created',\n+                    token: signupToken, // would be part of mail\n+                  });\n+                })\n+                .catch(error => res.status(400).send(error)),\n+              )\n+              .catch(error => res.status(400).json({\n+                status: 'unsuccessful',\n+                message: error.errors[0].message,\n+              }));\n+          }\n+        }).catch(error => res.status(400).send(error));\n+    }\n+  }\n+  static activateUser(req, res) {\n+\n+  }\n+  static signin(req, res) {","path":"server/controllers/user-controller-v4.js","position":117,"original_position":117,"commit_id":"d0d4876b45f069f9905030393652b83bc6454af3","original_commit_id":"d0d4876b45f069f9905030393652b83bc6454af3","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":"'res' is defined but never used                  no-unused-vars","created_at":"2017-08-19T19:59:13Z","updated_at":"2017-08-19T19:59:14Z","html_url":"https://github.com/fidelisojeah/Hello-Books/pull/6#discussion_r134099529","pull_request_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/comments/134099529"},"html":{"href":"https://github.com/fidelisojeah/Hello-Books/pull/6#discussion_r134099529"},"pull_request":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6","id":136618995,"html_url":"https://github.com/fidelisojeah/Hello-Books/pull/6","diff_url":"https://github.com/fidelisojeah/Hello-Books/pull/6.diff","patch_url":"https://github.com/fidelisojeah/Hello-Books/pull/6.patch","issue_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/6","number":6,"state":"open","locked":false,"title":"Authentication","user":{"login":"fidelisojeah","id":11561738,"avatar_url":"https://avatars2.githubusercontent.com/u/11561738?v=4","gravatar_id":"","url":"https://api.github.com/users/fidelisojeah","html_url":"https://github.com/fidelisojeah","followers_url":"https://api.github.com/users/fidelisojeah/followers","following_url":"https://api.github.com/users/fidelisojeah/following{/other_user}","gists_url":"https://api.github.com/users/fidelisojeah/gists{/gist_id}","starred_url":"https://api.github.com/users/fidelisojeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidelisojeah/subscriptions","organizations_url":"https://api.github.com/users/fidelisojeah/orgs","repos_url":"https://api.github.com/users/fidelisojeah/repos","events_url":"https://api.github.com/users/fidelisojeah/events{/privacy}","received_events_url":"https://api.github.com/users/fidelisojeah/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-19T19:41:52Z","updated_at":"2017-08-19T19:59:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6/commits","review_comments_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6/comments","review_comment_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/6/comments","statuses_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/statuses/d0d4876b45f069f9905030393652b83bc6454af3","head":{"label":"fidelisojeah:authentication","ref":"authentication","sha":"d0d4876b45f069f9905030393652b83bc6454af3","user":{"login":"fidelisojeah","id":11561738,"avatar_url":"https://avatars2.githubusercontent.com/u/11561738?v=4","gravatar_id":"","url":"https://api.github.com/users/fidelisojeah","html_url":"https://github.com/fidelisojeah","followers_url":"https://api.github.com/users/fidelisojeah/followers","following_url":"https://api.github.com/users/fidelisojeah/following{/other_user}","gists_url":"https://api.github.com/users/fidelisojeah/gists{/gist_id}","starred_url":"https://api.github.com/users/fidelisojeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidelisojeah/subscriptions","organizations_url":"https://api.github.com/users/fidelisojeah/orgs","repos_url":"https://api.github.com/users/fidelisojeah/repos","events_url":"https://api.github.com/users/fidelisojeah/events{/privacy}","received_events_url":"https://api.github.com/users/fidelisojeah/received_events","type":"User","site_admin":false},"repo":{"id":98308529,"name":"Hello-Books","full_name":"fidelisojeah/Hello-Books","owner":{"login":"fidelisojeah","id":11561738,"avatar_url":"https://avatars2.githubusercontent.com/u/11561738?v=4","gravatar_id":"","url":"https://api.github.com/users/fidelisojeah","html_url":"https://github.com/fidelisojeah","followers_url":"https://api.github.com/users/fidelisojeah/followers","following_url":"https://api.github.com/users/fidelisojeah/following{/other_user}","gists_url":"https://api.github.com/users/fidelisojeah/gists{/gist_id}","starred_url":"https://api.github.com/users/fidelisojeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidelisojeah/subscriptions","organizations_url":"https://api.github.com/users/fidelisojeah/orgs","repos_url":"https://api.github.com/users/fidelisojeah/repos","events_url":"https://api.github.com/users/fidelisojeah/events{/privacy}","received_events_url":"https://api.github.com/users/fidelisojeah/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fidelisojeah/Hello-Books","description":"Hello Books is an online application made to make library management easier","fork":false,"url":"https://api.github.com/repos/fidelisojeah/Hello-Books","forks_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/forks","keys_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/teams","hooks_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/hooks","issue_events_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/events{/number}","events_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/events","assignees_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/assignees{/user}","branches_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/branches{/branch}","tags_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/tags","blobs_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/refs{/sha}","trees_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/statuses/{sha}","languages_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/languages","stargazers_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/stargazers","contributors_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/contributors","subscribers_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/subscribers","subscription_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/subscription","commits_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/commits{/sha}","git_commits_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/commits{/sha}","comments_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/comments{/number}","issue_comment_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/comments{/number}","contents_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/contents/{+path}","compare_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/merges","archive_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/downloads","issues_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues{/number}","pulls_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls{/number}","milestones_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/milestones{/number}","notifications_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/labels{/name}","releases_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/releases{/id}","deployments_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/deployments","created_at":"2017-07-25T13:22:05Z","updated_at":"2017-08-10T23:50:58Z","pushed_at":"2017-08-19T19:58:45Z","git_url":"git://github.com/fidelisojeah/Hello-Books.git","ssh_url":"git@github.com:fidelisojeah/Hello-Books.git","clone_url":"https://github.com/fidelisojeah/Hello-Books.git","svn_url":"https://github.com/fidelisojeah/Hello-Books","homepage":"https://fidelisojeah.github.io/login.html","size":614,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"fidelisojeah:master","ref":"master","sha":"2da31bc1f5dfce5481de5bdc41485de3285dd1dc","user":{"login":"fidelisojeah","id":11561738,"avatar_url":"https://avatars2.githubusercontent.com/u/11561738?v=4","gravatar_id":"","url":"https://api.github.com/users/fidelisojeah","html_url":"https://github.com/fidelisojeah","followers_url":"https://api.github.com/users/fidelisojeah/followers","following_url":"https://api.github.com/users/fidelisojeah/following{/other_user}","gists_url":"https://api.github.com/users/fidelisojeah/gists{/gist_id}","starred_url":"https://api.github.com/users/fidelisojeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidelisojeah/subscriptions","organizations_url":"https://api.github.com/users/fidelisojeah/orgs","repos_url":"https://api.github.com/users/fidelisojeah/repos","events_url":"https://api.github.com/users/fidelisojeah/events{/privacy}","received_events_url":"https://api.github.com/users/fidelisojeah/received_events","type":"User","site_admin":false},"repo":{"id":98308529,"name":"Hello-Books","full_name":"fidelisojeah/Hello-Books","owner":{"login":"fidelisojeah","id":11561738,"avatar_url":"https://avatars2.githubusercontent.com/u/11561738?v=4","gravatar_id":"","url":"https://api.github.com/users/fidelisojeah","html_url":"https://github.com/fidelisojeah","followers_url":"https://api.github.com/users/fidelisojeah/followers","following_url":"https://api.github.com/users/fidelisojeah/following{/other_user}","gists_url":"https://api.github.com/users/fidelisojeah/gists{/gist_id}","starred_url":"https://api.github.com/users/fidelisojeah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fidelisojeah/subscriptions","organizations_url":"https://api.github.com/users/fidelisojeah/orgs","repos_url":"https://api.github.com/users/fidelisojeah/repos","events_url":"https://api.github.com/users/fidelisojeah/events{/privacy}","received_events_url":"https://api.github.com/users/fidelisojeah/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fidelisojeah/Hello-Books","description":"Hello Books is an online application made to make library management easier","fork":false,"url":"https://api.github.com/repos/fidelisojeah/Hello-Books","forks_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/forks","keys_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/teams","hooks_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/hooks","issue_events_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/events{/number}","events_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/events","assignees_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/assignees{/user}","branches_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/branches{/branch}","tags_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/tags","blobs_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/refs{/sha}","trees_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/statuses/{sha}","languages_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/languages","stargazers_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/stargazers","contributors_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/contributors","subscribers_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/subscribers","subscription_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/subscription","commits_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/commits{/sha}","git_commits_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/git/commits{/sha}","comments_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/comments{/number}","issue_comment_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/comments{/number}","contents_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/contents/{+path}","compare_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/merges","archive_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/downloads","issues_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues{/number}","pulls_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls{/number}","milestones_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/milestones{/number}","notifications_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/labels{/name}","releases_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/releases{/id}","deployments_url":"https://api.github.com/repos/fidelisojeah/Hello-Books/deployments","created_at":"2017-07-25T13:22:05Z","updated_at":"2017-08-10T23:50:58Z","pushed_at":"2017-08-19T19:58:45Z","git_url":"git://github.com/fidelisojeah/Hello-Books.git","ssh_url":"git@github.com:fidelisojeah/Hello-Books.git","clone_url":"https://github.com/fidelisojeah/Hello-Books.git","svn_url":"https://github.com/fidelisojeah/Hello-Books","homepage":"https://fidelisojeah.github.io/login.html","size":614,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6"},"html":{"href":"https://github.com/fidelisojeah/Hello-Books/pull/6"},"issue":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/6"},"comments":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/fidelisojeah/Hello-Books/statuses/d0d4876b45f069f9905030393652b83bc6454af3"}}}}
{"actor":{"display_login":"houndci-bot"}}