{"action":"created","comment":{"url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/comments/177658637","pull_request_review_id":107567294,"id":177658637,"diff_hunk":"@@ -0,0 +1,272 @@\n+# app/api/resources/auth.py\n+\"\"\"Contains user logic\"\"\"\n+\n+import os\n+import sys\n+import inspect\n+import random\n+import datetime\n+import json\n+\n+from functools import wraps\n+\n+import jwt\n+\n+from flask import jsonify, request, make_response, session\n+from flask_restful import Resource\n+from flask_restful.reqparse import RequestParser\n+from flasgger import swag_from\n+from werkzeug.security import check_password_hash, generate_password_hash\n+\n+\n+# solution to python 3 relative import messages\n+# use the inspect module because for os.path.abspath(__file__),\n+# the __file__ attribute is not always given\n+auth_dir = os.path.dirname(os.path.abspath(\n+    inspect.getfile(inspect.currentframe())))\n+resources_dir = os.path.dirname(auth_dir)\n+v2_dir = os.path.dirname(resources_dir)\n+api_dir = os.path.dirname(v2_dir)\n+app_dir = os.path.dirname(api_dir)\n+sys.path.insert(0, app_dir)\n+# sys.path.append(os.path.dirname)\n+\n+from app.db import db\n+from app.models.blacklist import Blacklist\n+from app.models.user import User\n+from app.models.log import Log\n+\n+\n+secret_key = os.environ.get('SECRET_KEY', 'MEGAtron35648')\n+\n+\n+# RequestParser and added arguments will know which fields to accept and how to validate those\n+user_request_parser = RequestParser(bundle_errors=True)\n+\n+user_request_parser.add_argument(\n+    \"first_name\", type=str, required=True,\n+    help=\"First name must be a valid string\")\n+\n+user_request_parser.add_argument(\n+    \"last_name\", type=str, required=True,\n+    help=\"Last name must be a valid string\")\n+\n+user_request_parser.add_argument(\n+    \"username\", type=str, required=True,\n+    help=\"Username must be a valid string\")\n+\n+user_request_parser.add_argument(\n+    \"password\", type=str, required=True,\n+    help=\"Password is required\")\n+\n+\n+def string_empty(string_var):\n+    \"\"\"Return true if string is empty\"\"\"\n+\n+    return not isinstance(string_var, str) or string_var in [' ', '']\n+\n+\n+def token_required(function):\n+    @wraps(function)\n+    def decorated_function(*args, **kwargs):\n+        access_token = None\n+\n+        if \"Authorization\" in request.headers:\n+            authorization = request.headers.get(\"Authorization\", None)\n+            if authorization:\n+                access_token = authorization.split(\" \")[1]","path":"app/api/v2/resources/auth.py","position":77,"original_position":77,"commit_id":"76295243a7b48d31e278c1276586951f18523630","original_commit_id":"76295243a7b48d31e278c1276586951f18523630","user":{"login":"Rwothoromo","id":7848682,"avatar_url":"https://avatars2.githubusercontent.com/u/7848682?v=4","gravatar_id":"","url":"https://api.github.com/users/Rwothoromo","html_url":"https://github.com/Rwothoromo","followers_url":"https://api.github.com/users/Rwothoromo/followers","following_url":"https://api.github.com/users/Rwothoromo/following{/other_user}","gists_url":"https://api.github.com/users/Rwothoromo/gists{/gist_id}","starred_url":"https://api.github.com/users/Rwothoromo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rwothoromo/subscriptions","organizations_url":"https://api.github.com/users/Rwothoromo/orgs","repos_url":"https://api.github.com/users/Rwothoromo/repos","events_url":"https://api.github.com/users/Rwothoromo/events{/privacy}","received_events_url":"https://api.github.com/users/Rwothoromo/received_events","type":"User","site_admin":false},"body":"Noted. I will adjust it to\r\n```\r\nauthorization = request.headers.get(\"Authorization\", None)\r\nif authorization:\r\n    authorization_list = authorization.split(\" \")\r\n    if len(authorization_list) > 1:\r\n        access_token = authorization_list[1]\r\n\r\n    if not access_token:\r\n        return {\"message\": \"No token provided\"}, 401\r\n```","created_at":"2018-03-28T07:25:54Z","updated_at":"2018-03-28T07:25:54Z","html_url":"https://github.com/Rwothoromo/WeConnect-App/pull/15#discussion_r177658637","pull_request_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/comments/177658637"},"html":{"href":"https://github.com/Rwothoromo/WeConnect-App/pull/15#discussion_r177658637"},"pull_request":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15"}},"in_reply_to_id":177569430},"pull_request":{"url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15","id":177580808,"html_url":"https://github.com/Rwothoromo/WeConnect-App/pull/15","diff_url":"https://github.com/Rwothoromo/WeConnect-App/pull/15.diff","patch_url":"https://github.com/Rwothoromo/WeConnect-App/pull/15.patch","issue_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/15","number":15,"state":"open","locked":false,"title":"Api complete with database","user":{"login":"Rwothoromo","id":7848682,"avatar_url":"https://avatars2.githubusercontent.com/u/7848682?v=4","gravatar_id":"","url":"https://api.github.com/users/Rwothoromo","html_url":"https://github.com/Rwothoromo","followers_url":"https://api.github.com/users/Rwothoromo/followers","following_url":"https://api.github.com/users/Rwothoromo/following{/other_user}","gists_url":"https://api.github.com/users/Rwothoromo/gists{/gist_id}","starred_url":"https://api.github.com/users/Rwothoromo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rwothoromo/subscriptions","organizations_url":"https://api.github.com/users/Rwothoromo/orgs","repos_url":"https://api.github.com/users/Rwothoromo/repos","events_url":"https://api.github.com/users/Rwothoromo/events{/privacy}","received_events_url":"https://api.github.com/users/Rwothoromo/received_events","type":"User","site_admin":false},"body":"The Api works with a database as per the url on the readme and on postman.\r\n\r\nRequesting final reviews @collin5","created_at":"2018-03-26T22:05:30Z","updated_at":"2018-03-28T07:25:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1eb04d300f62faa63d7fb9322a8e02b3a99e9502","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15/commits","review_comments_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15/comments","review_comment_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/15/comments","statuses_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/statuses/76295243a7b48d31e278c1276586951f18523630","head":{"label":"Rwothoromo:develop","ref":"develop","sha":"76295243a7b48d31e278c1276586951f18523630","user":{"login":"Rwothoromo","id":7848682,"avatar_url":"https://avatars2.githubusercontent.com/u/7848682?v=4","gravatar_id":"","url":"https://api.github.com/users/Rwothoromo","html_url":"https://github.com/Rwothoromo","followers_url":"https://api.github.com/users/Rwothoromo/followers","following_url":"https://api.github.com/users/Rwothoromo/following{/other_user}","gists_url":"https://api.github.com/users/Rwothoromo/gists{/gist_id}","starred_url":"https://api.github.com/users/Rwothoromo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rwothoromo/subscriptions","organizations_url":"https://api.github.com/users/Rwothoromo/orgs","repos_url":"https://api.github.com/users/Rwothoromo/repos","events_url":"https://api.github.com/users/Rwothoromo/events{/privacy}","received_events_url":"https://api.github.com/users/Rwothoromo/received_events","type":"User","site_admin":false},"repo":{"id":122054107,"name":"WeConnect-App","full_name":"Rwothoromo/WeConnect-App","owner":{"login":"Rwothoromo","id":7848682,"avatar_url":"https://avatars2.githubusercontent.com/u/7848682?v=4","gravatar_id":"","url":"https://api.github.com/users/Rwothoromo","html_url":"https://github.com/Rwothoromo","followers_url":"https://api.github.com/users/Rwothoromo/followers","following_url":"https://api.github.com/users/Rwothoromo/following{/other_user}","gists_url":"https://api.github.com/users/Rwothoromo/gists{/gist_id}","starred_url":"https://api.github.com/users/Rwothoromo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rwothoromo/subscriptions","organizations_url":"https://api.github.com/users/Rwothoromo/orgs","repos_url":"https://api.github.com/users/Rwothoromo/repos","events_url":"https://api.github.com/users/Rwothoromo/events{/privacy}","received_events_url":"https://api.github.com/users/Rwothoromo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Rwothoromo/WeConnect-App","description":"WeConnect brings businesses and users together, and allows users to review businesses.","fork":false,"url":"https://api.github.com/repos/Rwothoromo/WeConnect-App","forks_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/forks","keys_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/teams","hooks_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/hooks","issue_events_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/events{/number}","events_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/events","assignees_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/assignees{/user}","branches_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/branches{/branch}","tags_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/tags","blobs_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/refs{/sha}","trees_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/statuses/{sha}","languages_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/languages","stargazers_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/stargazers","contributors_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/contributors","subscribers_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/subscribers","subscription_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/subscription","commits_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/commits{/sha}","git_commits_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/commits{/sha}","comments_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/comments{/number}","issue_comment_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/comments{/number}","contents_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/contents/{+path}","compare_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/merges","archive_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/downloads","issues_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues{/number}","pulls_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls{/number}","milestones_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/milestones{/number}","notifications_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/labels{/name}","releases_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/releases{/id}","deployments_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/deployments","created_at":"2018-02-19T11:37:18Z","updated_at":"2018-03-21T08:29:50Z","pushed_at":"2018-03-28T06:42:48Z","git_url":"git://github.com/Rwothoromo/WeConnect-App.git","ssh_url":"git@github.com:Rwothoromo/WeConnect-App.git","clone_url":"https://github.com/Rwothoromo/WeConnect-App.git","svn_url":"https://github.com/Rwothoromo/WeConnect-App","homepage":null,"size":924,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"Rwothoromo:master","ref":"master","sha":"5b7b60adf5f3cacc4e22263d4764f208b0952a0f","user":{"login":"Rwothoromo","id":7848682,"avatar_url":"https://avatars2.githubusercontent.com/u/7848682?v=4","gravatar_id":"","url":"https://api.github.com/users/Rwothoromo","html_url":"https://github.com/Rwothoromo","followers_url":"https://api.github.com/users/Rwothoromo/followers","following_url":"https://api.github.com/users/Rwothoromo/following{/other_user}","gists_url":"https://api.github.com/users/Rwothoromo/gists{/gist_id}","starred_url":"https://api.github.com/users/Rwothoromo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rwothoromo/subscriptions","organizations_url":"https://api.github.com/users/Rwothoromo/orgs","repos_url":"https://api.github.com/users/Rwothoromo/repos","events_url":"https://api.github.com/users/Rwothoromo/events{/privacy}","received_events_url":"https://api.github.com/users/Rwothoromo/received_events","type":"User","site_admin":false},"repo":{"id":122054107,"name":"WeConnect-App","full_name":"Rwothoromo/WeConnect-App","owner":{"login":"Rwothoromo","id":7848682,"avatar_url":"https://avatars2.githubusercontent.com/u/7848682?v=4","gravatar_id":"","url":"https://api.github.com/users/Rwothoromo","html_url":"https://github.com/Rwothoromo","followers_url":"https://api.github.com/users/Rwothoromo/followers","following_url":"https://api.github.com/users/Rwothoromo/following{/other_user}","gists_url":"https://api.github.com/users/Rwothoromo/gists{/gist_id}","starred_url":"https://api.github.com/users/Rwothoromo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rwothoromo/subscriptions","organizations_url":"https://api.github.com/users/Rwothoromo/orgs","repos_url":"https://api.github.com/users/Rwothoromo/repos","events_url":"https://api.github.com/users/Rwothoromo/events{/privacy}","received_events_url":"https://api.github.com/users/Rwothoromo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Rwothoromo/WeConnect-App","description":"WeConnect brings businesses and users together, and allows users to review businesses.","fork":false,"url":"https://api.github.com/repos/Rwothoromo/WeConnect-App","forks_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/forks","keys_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/teams","hooks_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/hooks","issue_events_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/events{/number}","events_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/events","assignees_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/assignees{/user}","branches_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/branches{/branch}","tags_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/tags","blobs_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/refs{/sha}","trees_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/statuses/{sha}","languages_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/languages","stargazers_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/stargazers","contributors_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/contributors","subscribers_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/subscribers","subscription_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/subscription","commits_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/commits{/sha}","git_commits_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/git/commits{/sha}","comments_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/comments{/number}","issue_comment_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/comments{/number}","contents_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/contents/{+path}","compare_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/merges","archive_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/downloads","issues_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues{/number}","pulls_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls{/number}","milestones_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/milestones{/number}","notifications_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/labels{/name}","releases_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/releases{/id}","deployments_url":"https://api.github.com/repos/Rwothoromo/WeConnect-App/deployments","created_at":"2018-02-19T11:37:18Z","updated_at":"2018-03-21T08:29:50Z","pushed_at":"2018-03-28T06:42:48Z","git_url":"git://github.com/Rwothoromo/WeConnect-App.git","ssh_url":"git@github.com:Rwothoromo/WeConnect-App.git","clone_url":"https://github.com/Rwothoromo/WeConnect-App.git","svn_url":"https://github.com/Rwothoromo/WeConnect-App","homepage":null,"size":924,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15"},"html":{"href":"https://github.com/Rwothoromo/WeConnect-App/pull/15"},"issue":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/15"},"comments":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/Rwothoromo/WeConnect-App/statuses/76295243a7b48d31e278c1276586951f18523630"}},"author_association":"OWNER"}}
{"actor":{"display_login":"Rwothoromo"}}