{"action":"created","comment":{"url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/comments/220143686","pull_request_review_id":158480339,"id":220143686,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMDE0MzY4Ng==","diff_hunk":"@@ -1,24 +1,53 @@\n-import React from 'react';\n+import React, { Component } from 'react';\n+import PropTypes from 'prop-types';\n+import { notify } from 'react-notify-toast';\n+import { doSignInWithGoogle } from '../firebase';\n \n-const Login = () => (\n-  <div className=\"login_page\">\n-    <div className=\"login_details\">\n-      <div className=\"login_logo\">\n-        <div>A</div>\n-        <img className=\"logo\" src=\"/logo.png\" alt=\"Andela Logo\" />\n-      </div>\n-      <div className=\"login_title\">\n-        <h1>ESA</h1>\n-      </div>\n-      <div className=\"login_link\">\n-        {/* eslint-disable jsx-a11y/anchor-is-valid */}\n-        <a href=\"#\">\n-          <img src=\"/google.png\" alt=\"andela-logo\" />\n-          <span>LOGIN TO GET STARTED</span>\n-        </a>\n+class Login extends Component {\n+  onLogin = () => {\n+    const { setCurrentUser, history } = this.props;\n+    doSignInWithGoogle().then((user, error) => {\n+      if (error) {\n+        notify.show('Unable to login with google!', 'error');\n+      } else if (user.user.email.match(/.*@andela.com$/)) {\n+        setCurrentUser(user);\n+        history.push('/');\n+        notify.show(`Hello ${user.user.displayName} ! You have Logged in Successfully!`, 'success');\n+      } else { notify.show('Login failed! Please login with your andela email!', 'error'); }\n+    });\n+  }\n+\n+  render() {\n+    return (\n+      <div className=\"login_page\">\n+        <div className=\"login_details\">\n+          <div className=\"login_logo\">\n+            <div>A</div>\n+            <img className=\"logo\" src=\"/logo.png\" alt=\"Andela Logo\" />\n+          </div>\n+          <div className=\"login_title\">\n+            <h1>ESA</h1>\n+          </div>\n+          <div className=\"login_link\">\n+            {/* eslint-disable jsx-a11y/anchor-is-valid */}\n+            <a href=\"#\" onClick={this.onLogin()}>","path":"src/components/login.jsx","position":50,"original_position":50,"commit_id":"3a972deae3e9ad3294ee2e25264919d1d3831dd6","original_commit_id":"3a972deae3e9ad3294ee2e25264919d1d3831dd6","user":{"login":"IAMOTZ","id":26048536,"node_id":"MDQ6VXNlcjI2MDQ4NTM2","avatar_url":"https://avatars0.githubusercontent.com/u/26048536?v=4","gravatar_id":"","url":"https://api.github.com/users/IAMOTZ","html_url":"https://github.com/IAMOTZ","followers_url":"https://api.github.com/users/IAMOTZ/followers","following_url":"https://api.github.com/users/IAMOTZ/following{/other_user}","gists_url":"https://api.github.com/users/IAMOTZ/gists{/gist_id}","starred_url":"https://api.github.com/users/IAMOTZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IAMOTZ/subscriptions","organizations_url":"https://api.github.com/users/IAMOTZ/orgs","repos_url":"https://api.github.com/users/IAMOTZ/repos","events_url":"https://api.github.com/users/IAMOTZ/events{/privacy}","received_events_url":"https://api.github.com/users/IAMOTZ/received_events","type":"User","site_admin":false},"body":"I am not sure if the way you are accessing `this.onLogin` here is proper.\r\nFrom what I see here:\r\n```\r\n<a href=\"#\" onClick={this.onLogin()}>\r\n```\r\nAs soon as this page loads, the `onLogin` function would be triggered and I am sure that is not the intent.","created_at":"2018-09-25T10:47:57Z","updated_at":"2018-09-25T10:48:13Z","html_url":"https://github.com/andela/bp-esa-frontend/pull/9#discussion_r220143686","pull_request_url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/comments/220143686"},"html":{"href":"https://github.com/andela/bp-esa-frontend/pull/9#discussion_r220143686"},"pull_request":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9","id":217637814,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE3NjM3ODE0","html_url":"https://github.com/andela/bp-esa-frontend/pull/9","diff_url":"https://github.com/andela/bp-esa-frontend/pull/9.diff","patch_url":"https://github.com/andela/bp-esa-frontend/pull/9.patch","issue_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues/9","number":9,"state":"open","locked":false,"title":"#160437221 Add google authentication","user":{"login":"Betty-Kebenei","id":19909781,"node_id":"MDQ6VXNlcjE5OTA5Nzgx","avatar_url":"https://avatars0.githubusercontent.com/u/19909781?v=4","gravatar_id":"","url":"https://api.github.com/users/Betty-Kebenei","html_url":"https://github.com/Betty-Kebenei","followers_url":"https://api.github.com/users/Betty-Kebenei/followers","following_url":"https://api.github.com/users/Betty-Kebenei/following{/other_user}","gists_url":"https://api.github.com/users/Betty-Kebenei/gists{/gist_id}","starred_url":"https://api.github.com/users/Betty-Kebenei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Betty-Kebenei/subscriptions","organizations_url":"https://api.github.com/users/Betty-Kebenei/orgs","repos_url":"https://api.github.com/users/Betty-Kebenei/repos","events_url":"https://api.github.com/users/Betty-Kebenei/events{/privacy}","received_events_url":"https://api.github.com/users/Betty-Kebenei/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\n- Login a user with firebase google authentication.\r\n- Logout a user firebase google authentication.\r\n- Protect the routes that are not supposed to be accessed if a user is not logged in.\r\n- Restrict google authentication to `@andela.com` domain.\r\n\r\n#### Description of Task to be completed?\r\n- Set up the firebase configuration for google authentication.\r\n- Add signin and signout functions.\r\n- Add regex to restrict login to emails with specific domain.\r\n- Add a custom AuthenticatedRoute for protected routes.\r\n\r\n#### How should this be manually tested?\r\n- Clone and set up the project using the instruction in the README.\r\n- Create a `.env` file and add the necessary variables as listed in  `src/firebase/firebase.js`\r\n**NOTE:** Variables are to be provided by Andela's Firebase Admin through Dominic (ESA's devOps engineer).\r\n- Use `npm start` to start the application\r\n- The application should direct you to the login page; when you click login with google, you should be directed to a list of emails.\r\n- Select an andelan email so as to login successfully.\r\n\r\n#### What are the relevant pivotal tracker stories?\r\n`#160437221`","created_at":"2018-09-24T12:21:30Z","updated_at":"2018-09-25T10:48:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e5e8a550f820a67d792973b1d911088b7128f60a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9/commits","review_comments_url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9/comments","review_comment_url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues/9/comments","statuses_url":"https://api.github.com/repos/andela/bp-esa-frontend/statuses/3a972deae3e9ad3294ee2e25264919d1d3831dd6","head":{"label":"andela:ft-google-auth-160437221","ref":"ft-google-auth-160437221","sha":"3a972deae3e9ad3294ee2e25264919d1d3831dd6","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":137343490,"node_id":"MDEwOlJlcG9zaXRvcnkxMzczNDM0OTA=","name":"bp-esa-frontend","full_name":"andela/bp-esa-frontend","private":false,"owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/andela/bp-esa-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/andela/bp-esa-frontend","forks_url":"https://api.github.com/repos/andela/bp-esa-frontend/forks","keys_url":"https://api.github.com/repos/andela/bp-esa-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/bp-esa-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/bp-esa-frontend/teams","hooks_url":"https://api.github.com/repos/andela/bp-esa-frontend/hooks","issue_events_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/andela/bp-esa-frontend/events","assignees_url":"https://api.github.com/repos/andela/bp-esa-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/andela/bp-esa-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/andela/bp-esa-frontend/tags","blobs_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/bp-esa-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/bp-esa-frontend/languages","stargazers_url":"https://api.github.com/repos/andela/bp-esa-frontend/stargazers","contributors_url":"https://api.github.com/repos/andela/bp-esa-frontend/contributors","subscribers_url":"https://api.github.com/repos/andela/bp-esa-frontend/subscribers","subscription_url":"https://api.github.com/repos/andela/bp-esa-frontend/subscription","commits_url":"https://api.github.com/repos/andela/bp-esa-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/bp-esa-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/bp-esa-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/andela/bp-esa-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/bp-esa-frontend/merges","archive_url":"https://api.github.com/repos/andela/bp-esa-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/bp-esa-frontend/downloads","issues_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/bp-esa-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/bp-esa-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/bp-esa-frontend/labels{/name}","releases_url":"https://api.github.com/repos/andela/bp-esa-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/andela/bp-esa-frontend/deployments","created_at":"2018-06-14T10:29:35Z","updated_at":"2018-09-24T13:48:49Z","pushed_at":"2018-09-25T09:28:44Z","git_url":"git://github.com/andela/bp-esa-frontend.git","ssh_url":"git@github.com:andela/bp-esa-frontend.git","clone_url":"https://github.com/andela/bp-esa-frontend.git","svn_url":"https://github.com/andela/bp-esa-frontend","homepage":null,"size":494,"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":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"base":{"label":"andela:develop","ref":"develop","sha":"f30d4865cbcc65415359970d29157b3f0e6e020a","user":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"repo":{"id":137343490,"node_id":"MDEwOlJlcG9zaXRvcnkxMzczNDM0OTA=","name":"bp-esa-frontend","full_name":"andela/bp-esa-frontend","private":false,"owner":{"login":"andela","id":4100206,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDAyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/4100206?v=4","gravatar_id":"","url":"https://api.github.com/users/andela","html_url":"https://github.com/andela","followers_url":"https://api.github.com/users/andela/followers","following_url":"https://api.github.com/users/andela/following{/other_user}","gists_url":"https://api.github.com/users/andela/gists{/gist_id}","starred_url":"https://api.github.com/users/andela/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andela/subscriptions","organizations_url":"https://api.github.com/users/andela/orgs","repos_url":"https://api.github.com/users/andela/repos","events_url":"https://api.github.com/users/andela/events{/privacy}","received_events_url":"https://api.github.com/users/andela/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/andela/bp-esa-frontend","description":null,"fork":false,"url":"https://api.github.com/repos/andela/bp-esa-frontend","forks_url":"https://api.github.com/repos/andela/bp-esa-frontend/forks","keys_url":"https://api.github.com/repos/andela/bp-esa-frontend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andela/bp-esa-frontend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andela/bp-esa-frontend/teams","hooks_url":"https://api.github.com/repos/andela/bp-esa-frontend/hooks","issue_events_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues/events{/number}","events_url":"https://api.github.com/repos/andela/bp-esa-frontend/events","assignees_url":"https://api.github.com/repos/andela/bp-esa-frontend/assignees{/user}","branches_url":"https://api.github.com/repos/andela/bp-esa-frontend/branches{/branch}","tags_url":"https://api.github.com/repos/andela/bp-esa-frontend/tags","blobs_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/refs{/sha}","trees_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andela/bp-esa-frontend/statuses/{sha}","languages_url":"https://api.github.com/repos/andela/bp-esa-frontend/languages","stargazers_url":"https://api.github.com/repos/andela/bp-esa-frontend/stargazers","contributors_url":"https://api.github.com/repos/andela/bp-esa-frontend/contributors","subscribers_url":"https://api.github.com/repos/andela/bp-esa-frontend/subscribers","subscription_url":"https://api.github.com/repos/andela/bp-esa-frontend/subscription","commits_url":"https://api.github.com/repos/andela/bp-esa-frontend/commits{/sha}","git_commits_url":"https://api.github.com/repos/andela/bp-esa-frontend/git/commits{/sha}","comments_url":"https://api.github.com/repos/andela/bp-esa-frontend/comments{/number}","issue_comment_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues/comments{/number}","contents_url":"https://api.github.com/repos/andela/bp-esa-frontend/contents/{+path}","compare_url":"https://api.github.com/repos/andela/bp-esa-frontend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andela/bp-esa-frontend/merges","archive_url":"https://api.github.com/repos/andela/bp-esa-frontend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andela/bp-esa-frontend/downloads","issues_url":"https://api.github.com/repos/andela/bp-esa-frontend/issues{/number}","pulls_url":"https://api.github.com/repos/andela/bp-esa-frontend/pulls{/number}","milestones_url":"https://api.github.com/repos/andela/bp-esa-frontend/milestones{/number}","notifications_url":"https://api.github.com/repos/andela/bp-esa-frontend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andela/bp-esa-frontend/labels{/name}","releases_url":"https://api.github.com/repos/andela/bp-esa-frontend/releases{/id}","deployments_url":"https://api.github.com/repos/andela/bp-esa-frontend/deployments","created_at":"2018-06-14T10:29:35Z","updated_at":"2018-09-24T13:48:49Z","pushed_at":"2018-09-25T09:28:44Z","git_url":"git://github.com/andela/bp-esa-frontend.git","ssh_url":"git@github.com:andela/bp-esa-frontend.git","clone_url":"https://github.com/andela/bp-esa-frontend.git","svn_url":"https://github.com/andela/bp-esa-frontend","homepage":null,"size":494,"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":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9"},"html":{"href":"https://github.com/andela/bp-esa-frontend/pull/9"},"issue":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/issues/9"},"comments":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/andela/bp-esa-frontend/statuses/3a972deae3e9ad3294ee2e25264919d1d3831dd6"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"IAMOTZ"}}