{"action":"created","comment":{"url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/comments/110088571","pull_request_review_id":31234004,"id":110088571,"diff_hunk":"@@ -0,0 +1,95 @@\n+\"\"\"\n+Authentication settings for the BucketList API.\n+\n+Password verification and user registration takes place here.\n+\"\"\"\n+from flask import g, jsonify, request\n+from flask_httpauth import HTTPBasicAuth\n+\n+from . import authe\n+from app import errors\n+from app.decorators import json\n+from app.models import User\n+\n+auth = HTTPBasicAuth()\n+\n+\n+@auth.verify_password\n+def verify_password(token, password):\n+    \"\"\"\n+    Verify token.\n+\n+    Verify token, password doesn't need to be present here. The token is\n+    going to be in the request headers always.\n+    \"\"\"\n+    user = User.verify_auth_token(token)\n+\n+    if not user:\n+        return False\n+\n+    g.user = user\n+    return True\n+\n+\n+@authe.route('/login', methods=['POST'])\n+def login():\n+    \"\"\"\n+    Verify a user's identity.\n+\n+    Verify the user's identity and returns a token.\n+    \"\"\"\n+    if not request.json:\n+        return errors.bad_request(\"No JSON file detected.\")\n+\n+    username = request.json.get('username')\n+    password = request.json.get('password')\n+\n+    if not username or not password:\n+        return errors.bad_request(\"username or password missing.\")\n+\n+    user = User.query.filter_by(username=username).first()\n+    if not user or not user.verify_password(password):\n+        return errors.bad_request(\"Username and password doesn't match.\")\n+\n+    token = user.generate_auth_token()\n+    return jsonify({'token': token}), 200\n+\n+\n+@authe.route('/register', methods=['POST'])\n+@json\n+def register_user():\n+    \"\"\"\n+    Create a new user.\n+\n+    Creates a new user in the application.","path":"app/auth/routes.py","position":64,"original_position":64,"commit_id":"5a4a0ad48f9b0aa38e9fdc0530abdc08377f5cb3","original_commit_id":"86aff8fe1ffaf5828422669a2e7add9bed9dbf91","user":{"login":"andela-bolajide","id":25608335,"avatar_url":"https://avatars3.githubusercontent.com/u/25608335?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-bolajide","html_url":"https://github.com/andela-bolajide","followers_url":"https://api.github.com/users/andela-bolajide/followers","following_url":"https://api.github.com/users/andela-bolajide/following{/other_user}","gists_url":"https://api.github.com/users/andela-bolajide/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-bolajide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-bolajide/subscriptions","organizations_url":"https://api.github.com/users/andela-bolajide/orgs","repos_url":"https://api.github.com/users/andela-bolajide/repos","events_url":"https://api.github.com/users/andela-bolajide/events{/privacy}","received_events_url":"https://api.github.com/users/andela-bolajide/received_events","type":"User","site_admin":false},"body":"I've corrected this.","created_at":"2017-04-06T06:48:13Z","updated_at":"2017-04-06T06:48:13Z","html_url":"https://github.com/andela-bolajide/BucketListAPI/pull/1#discussion_r110088571","pull_request_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/comments/110088571"},"html":{"href":"https://github.com/andela-bolajide/BucketListAPI/pull/1#discussion_r110088571"},"pull_request":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1","id":113706179,"html_url":"https://github.com/andela-bolajide/BucketListAPI/pull/1","diff_url":"https://github.com/andela-bolajide/BucketListAPI/pull/1.diff","patch_url":"https://github.com/andela-bolajide/BucketListAPI/pull/1.patch","issue_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/1","number":1,"state":"open","locked":false,"title":"Peer Review for my BucketList Application API","user":{"login":"andela-bolajide","id":25608335,"avatar_url":"https://avatars3.githubusercontent.com/u/25608335?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-bolajide","html_url":"https://github.com/andela-bolajide","followers_url":"https://api.github.com/users/andela-bolajide/followers","following_url":"https://api.github.com/users/andela-bolajide/following{/other_user}","gists_url":"https://api.github.com/users/andela-bolajide/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-bolajide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-bolajide/subscriptions","organizations_url":"https://api.github.com/users/andela-bolajide/orgs","repos_url":"https://api.github.com/users/andela-bolajide/repos","events_url":"https://api.github.com/users/andela-bolajide/events{/privacy}","received_events_url":"https://api.github.com/users/andela-bolajide/received_events","type":"User","site_admin":false},"body":"## What does this PR do?\r\n\r\nIt serves as my first output for Checkpoint 2\r\n\r\n## Description of Task to be completed?\r\n\r\nI am to create a Flask API for a bucket list service. Specification for the API is shown below. You may use any database you prefer for this assignment.\r\n\r\n| EndPoint                                 | Functionality                 | Public Access|\r\n| -----------------------------------------|:-----------------------------:|-------------:|\r\n| **POST** /auth/register                  | Register a user               |    TRUE      |\r\n| **POST** /auth/login                     | Logs a user in                |    TRUE      |\r\n| **POST** /bucketlists/                   | Create a new bucket list      |    FALSE     |\r\n| **GET** /bucketlists/                    | List all created bucket lists |    FALSE     |\r\n| **GET** /bucketlists/id                  | Get single bucket list        |    FALSE     |\r\n| **PUT** /bucketlists/id                  | Update a bucket list          |    FALSE     |\r\n| **DELETE** /bucketlists/id               | Delete a bucket list          |    FALSE     |\r\n| **POST** /bucketlists/id                   | Create a new item bucket list |    FALSE     |\r\n| **PUT** /bucketlists/id/items/item_id      | Update a bucket list item     |    FALSE     |\r\n| **DELETE** /bucketlists/id/items/item_id   | Delete an item in bucket list |    FALSE     |\r\n\r\n## How should this be manually tested?\r\n\r\nInstructions have been included in the README file.\r\n\r\n## Screenshot\r\n\r\nThis is a view of how to use the API using POSTMAN.\r\n\r\n<img width=\"988\" alt=\"screen shot 2017-03-31 at 6 46 11 pm\" src=\"https://cloud.githubusercontent.com/assets/25608335/24562591/28c6e8ae-1643-11e7-90cc-7b04bbc76822.png\">\r\n","created_at":"2017-03-31T18:27:22Z","updated_at":"2017-04-06T06:48:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc11908f8743dd08e1d6e1011c703ef26746e14c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1/commits","review_comments_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1/comments","review_comment_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/1/comments","statuses_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/statuses/5a4a0ad48f9b0aa38e9fdc0530abdc08377f5cb3","head":{"label":"andela-bolajide:develop","ref":"develop","sha":"5a4a0ad48f9b0aa38e9fdc0530abdc08377f5cb3","user":{"login":"andela-bolajide","id":25608335,"avatar_url":"https://avatars3.githubusercontent.com/u/25608335?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-bolajide","html_url":"https://github.com/andela-bolajide","followers_url":"https://api.github.com/users/andela-bolajide/followers","following_url":"https://api.github.com/users/andela-bolajide/following{/other_user}","gists_url":"https://api.github.com/users/andela-bolajide/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-bolajide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-bolajide/subscriptions","organizations_url":"https://api.github.com/users/andela-bolajide/orgs","repos_url":"https://api.github.com/users/andela-bolajide/repos","events_url":"https://api.github.com/users/andela-bolajide/events{/privacy}","received_events_url":"https://api.github.com/users/andela-bolajide/received_events","type":"User","site_admin":false},"repo":{"id":84458293,"name":"BucketListAPI","full_name":"andela-bolajide/BucketListAPI","owner":{"login":"andela-bolajide","id":25608335,"avatar_url":"https://avatars3.githubusercontent.com/u/25608335?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-bolajide","html_url":"https://github.com/andela-bolajide","followers_url":"https://api.github.com/users/andela-bolajide/followers","following_url":"https://api.github.com/users/andela-bolajide/following{/other_user}","gists_url":"https://api.github.com/users/andela-bolajide/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-bolajide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-bolajide/subscriptions","organizations_url":"https://api.github.com/users/andela-bolajide/orgs","repos_url":"https://api.github.com/users/andela-bolajide/repos","events_url":"https://api.github.com/users/andela-bolajide/events{/privacy}","received_events_url":"https://api.github.com/users/andela-bolajide/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-bolajide/BucketListAPI","description":"An API for a BucketList service built using the FLASK Framework.","fork":false,"url":"https://api.github.com/repos/andela-bolajide/BucketListAPI","forks_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/forks","keys_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/teams","hooks_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/hooks","issue_events_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/events{/number}","events_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/events","assignees_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/assignees{/user}","branches_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/branches{/branch}","tags_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/tags","blobs_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/languages","stargazers_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/stargazers","contributors_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/contributors","subscribers_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/subscribers","subscription_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/subscription","commits_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/contents/{+path}","compare_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/merges","archive_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/downloads","issues_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues{/number}","pulls_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/labels{/name}","releases_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/releases{/id}","deployments_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/deployments","created_at":"2017-03-09T15:35:24Z","updated_at":"2017-04-05T19:40:26Z","pushed_at":"2017-04-05T23:42:30Z","git_url":"git://github.com/andela-bolajide/BucketListAPI.git","ssh_url":"git@github.com:andela-bolajide/BucketListAPI.git","clone_url":"https://github.com/andela-bolajide/BucketListAPI.git","svn_url":"https://github.com/andela-bolajide/BucketListAPI","homepage":"https://proton-bucketlistapi.herokuapp.com","size":1228,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"andela-bolajide:master","ref":"master","sha":"3e1973030c319c1858a2cce6b6a54e63a6dbe3f7","user":{"login":"andela-bolajide","id":25608335,"avatar_url":"https://avatars3.githubusercontent.com/u/25608335?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-bolajide","html_url":"https://github.com/andela-bolajide","followers_url":"https://api.github.com/users/andela-bolajide/followers","following_url":"https://api.github.com/users/andela-bolajide/following{/other_user}","gists_url":"https://api.github.com/users/andela-bolajide/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-bolajide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-bolajide/subscriptions","organizations_url":"https://api.github.com/users/andela-bolajide/orgs","repos_url":"https://api.github.com/users/andela-bolajide/repos","events_url":"https://api.github.com/users/andela-bolajide/events{/privacy}","received_events_url":"https://api.github.com/users/andela-bolajide/received_events","type":"User","site_admin":false},"repo":{"id":84458293,"name":"BucketListAPI","full_name":"andela-bolajide/BucketListAPI","owner":{"login":"andela-bolajide","id":25608335,"avatar_url":"https://avatars3.githubusercontent.com/u/25608335?v=3","gravatar_id":"","url":"https://api.github.com/users/andela-bolajide","html_url":"https://github.com/andela-bolajide","followers_url":"https://api.github.com/users/andela-bolajide/followers","following_url":"https://api.github.com/users/andela-bolajide/following{/other_user}","gists_url":"https://api.github.com/users/andela-bolajide/gists{/gist_id}","starred_url":"https://api.github.com/users/andela-bolajide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela-bolajide/subscriptions","organizations_url":"https://api.github.com/users/andela-bolajide/orgs","repos_url":"https://api.github.com/users/andela-bolajide/repos","events_url":"https://api.github.com/users/andela-bolajide/events{/privacy}","received_events_url":"https://api.github.com/users/andela-bolajide/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andela-bolajide/BucketListAPI","description":"An API for a BucketList service built using the FLASK Framework.","fork":false,"url":"https://api.github.com/repos/andela-bolajide/BucketListAPI","forks_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/forks","keys_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/teams","hooks_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/hooks","issue_events_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/events{/number}","events_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/events","assignees_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/assignees{/user}","branches_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/branches{/branch}","tags_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/tags","blobs_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/statuses/{sha}","languages_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/languages","stargazers_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/stargazers","contributors_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/contributors","subscribers_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/subscribers","subscription_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/subscription","commits_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/contents/{+path}","compare_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/merges","archive_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/downloads","issues_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues{/number}","pulls_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls{/number}","milestones_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/milestones{/number}","notifications_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/labels{/name}","releases_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/releases{/id}","deployments_url":"https://api.github.com/repos/andela-bolajide/BucketListAPI/deployments","created_at":"2017-03-09T15:35:24Z","updated_at":"2017-04-05T19:40:26Z","pushed_at":"2017-04-05T23:42:30Z","git_url":"git://github.com/andela-bolajide/BucketListAPI.git","ssh_url":"git@github.com:andela-bolajide/BucketListAPI.git","clone_url":"https://github.com/andela-bolajide/BucketListAPI.git","svn_url":"https://github.com/andela-bolajide/BucketListAPI","homepage":"https://proton-bucketlistapi.herokuapp.com","size":1228,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1"},"html":{"href":"https://github.com/andela-bolajide/BucketListAPI/pull/1"},"issue":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/1"},"comments":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/andela-bolajide/BucketListAPI/statuses/5a4a0ad48f9b0aa38e9fdc0530abdc08377f5cb3"}}}}
{"actor":{"display_login":"andela-bolajide"}}