{"action":"created","comment":{"url":"https://api.github.com/repos/communityshare/communityshare/pulls/comments/83567445","pull_request_review_id":4402936,"id":83567445,"diff_hunk":"@@ -61,62 +61,64 @@ module.factory(\n       'Basic:api:' + key;\n         $cookies.apiKey = key;\n     };\n-    Authenticator.setEmail = function( email ) {\n-        $cookies.email = email;\n+    Authenticator.setID = function( id ) {\n+        $cookies.id = id;\n     };\n \n-    Authenticator.authenticateFromCookie =\n-    function() {\n-        var deferred = $q.defer();\n-        var apiKey = $cookies.apiKey;\n-        var email = $cookies.email;\n-        if ( ( apiKey ) && ( email ) ){\n-            Authenticator.setApiKey( apiKey );\n-            var userPromise = User.getByEmail( email );\n-            userPromise.then(\n-          function( user ) {\n-              SessionBase.setUser( user );\n-          },\n-          function( message ) {\n-              SessionBase.setUser( undefined );\n-              deferred.reject( message );\n-          }\n-        );\n-        } else {\n-            var message = 'No cookie found';\n+    Authenticator.authenticateFromCookie = function() {\n+        Authenticator.setApiKey( $cookies.apiKey );\n+        User.get( $cookies.id )\n+        .then( function( user ) {\n+            SessionBase.setUser( user );\n+        })\n+        .catch( function( message ) {\n             SessionBase.setUser( undefined );\n-            deferred.reject( message );\n-        }\n+            throw message;\n+        });\n     };\n \n-    Authenticator.authenticateWithEmailAndPassword =\n-    function( email, password ) {\n-        $http.defaults.headers.common.Authorization =\n-        'Basic:' + email + ':' + password;\n-        var url = '/api/requestapikey';\n-        var promiseApiKey = $http( {\n-            url: url,\n+    Authenticator.authenticateWithEmailAndPassword = function( email, password ) {\n+        $http.defaults.headers.common.Authorization = `Basic:${email}:${password}`;\n+        SessionBase.clearUser();\n+        return $http( {\n+            url: '/api/requestapikey',\n             method: 'GET'\n-        } );\n-        promiseApiKey.then(\n-        function( response ) {\n-            var apiKey = response.data.apiKey;\n+        } )\n+        .then( function( { data: { apiKey, user } } ) {\n+            const userObj = User.make( user );\n             Authenticator.setApiKey( apiKey );\n-            $cookies.email = email;\n-        },\n-        function( response ) {\n+            Authenticator.setID( userObj.id );\n+            SessionBase.setUser( userObj );\n+        } )\n+        .catch( function( response ) {\n+            SessionBase.setUser( undefined );\n         } );\n-        var userPromise = User.getByEmail( email );\n+    };\n+\n+    Authenticator.signUp = function( user, password ) {\n         SessionBase.clearUser();\n-        userPromise.then(\n-        function( user ) {\n+        return $http( {\n+            method: 'POST',\n+            url: '/api/usersignup',\n+            data: {\n+                'user': user.toData(),\n+                'password': password,\n+            },\n+        } )\n+        .then( function( { data: { data, apiKey } } ) {\n+            const user = User.make( data );\n+            Authenticator.setApiKey( apiKey );\n+            Authenticator.setID( user.id );","path":"static/js/services/authentication_services.js","position":91,"original_position":91,"commit_id":"dd78fdf7b1b794dcaea2166d0565caaf7449a810","original_commit_id":"dd78fdf7b1b794dcaea2166d0565caaf7449a810","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","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":"Expected indentation of 1 tab character but found 0   indent","created_at":"2016-10-17T01:42:14Z","updated_at":"2016-10-17T01:42:14Z","html_url":"https://github.com/communityshare/communityshare/pull/220#discussion_r83567445","pull_request_url":"https://api.github.com/repos/communityshare/communityshare/pulls/220","_links":{"self":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/comments/83567445"},"html":{"href":"https://github.com/communityshare/communityshare/pull/220#discussion_r83567445"},"pull_request":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/220"}}},"pull_request":{"url":"https://api.github.com/repos/communityshare/communityshare/pulls/220","id":89549212,"html_url":"https://github.com/communityshare/communityshare/pull/220","diff_url":"https://github.com/communityshare/communityshare/pull/220.diff","patch_url":"https://github.com/communityshare/communityshare/pull/220.patch","issue_url":"https://api.github.com/repos/communityshare/communityshare/issues/220","number":220,"state":"open","locked":false,"title":"Remove /api/userbyemail","user":{"login":"seanastephens","id":5893305,"avatar_url":"https://avatars.githubusercontent.com/u/5893305?v=3","gravatar_id":"","url":"https://api.github.com/users/seanastephens","html_url":"https://github.com/seanastephens","followers_url":"https://api.github.com/users/seanastephens/followers","following_url":"https://api.github.com/users/seanastephens/following{/other_user}","gists_url":"https://api.github.com/users/seanastephens/gists{/gist_id}","starred_url":"https://api.github.com/users/seanastephens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanastephens/subscriptions","organizations_url":"https://api.github.com/users/seanastephens/orgs","repos_url":"https://api.github.com/users/seanastephens/repos","events_url":"https://api.github.com/users/seanastephens/events{/privacy}","received_events_url":"https://api.github.com/users/seanastephens/received_events","type":"User","site_admin":false},"body":"Removes the `/api/userbyemail/<email>` endpoint.\r\n\r\nThis was used to fetch the user object when authenticating from cookie. In that scenario the client does not know the user's id, and so this endpoint was used to work around this. Now, `/api/requestapikey` returns the `User` object (like `/api/signup`), and the `id` is saved in the cookie next to `apiKey`.\r\n\r\n#### Testing\r\n\r\n1. Start logged out\r\n2. Log in as an existing user (testing that log in from email/password works).\r\n3. Refresh the page (testing that the cookie is OK).\r\n4. Log out (testing that the cookie updates and convinces authentication to indicate we are logged out).\r\n5. Sign up as a new user (testing that sign up is OK).\r\n6. Refresh the page (testing that sign up leaves cookie OK).","created_at":"2016-10-17T01:31:57Z","updated_at":"2016-10-17T01:42:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/communityshare/communityshare/pulls/220/commits","review_comments_url":"https://api.github.com/repos/communityshare/communityshare/pulls/220/comments","review_comment_url":"https://api.github.com/repos/communityshare/communityshare/pulls/comments{/number}","comments_url":"https://api.github.com/repos/communityshare/communityshare/issues/220/comments","statuses_url":"https://api.github.com/repos/communityshare/communityshare/statuses/dd78fdf7b1b794dcaea2166d0565caaf7449a810","head":{"label":"communityshare:remove/userbyemail","ref":"remove/userbyemail","sha":"dd78fdf7b1b794dcaea2166d0565caaf7449a810","user":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"repo":{"id":18902595,"name":"communityshare","full_name":"communityshare/communityshare","owner":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/communityshare/communityshare","description":"An online network connecting educators with community partners","fork":false,"url":"https://api.github.com/repos/communityshare/communityshare","forks_url":"https://api.github.com/repos/communityshare/communityshare/forks","keys_url":"https://api.github.com/repos/communityshare/communityshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/communityshare/communityshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/communityshare/communityshare/teams","hooks_url":"https://api.github.com/repos/communityshare/communityshare/hooks","issue_events_url":"https://api.github.com/repos/communityshare/communityshare/issues/events{/number}","events_url":"https://api.github.com/repos/communityshare/communityshare/events","assignees_url":"https://api.github.com/repos/communityshare/communityshare/assignees{/user}","branches_url":"https://api.github.com/repos/communityshare/communityshare/branches{/branch}","tags_url":"https://api.github.com/repos/communityshare/communityshare/tags","blobs_url":"https://api.github.com/repos/communityshare/communityshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/communityshare/communityshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/communityshare/communityshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/communityshare/communityshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/communityshare/communityshare/statuses/{sha}","languages_url":"https://api.github.com/repos/communityshare/communityshare/languages","stargazers_url":"https://api.github.com/repos/communityshare/communityshare/stargazers","contributors_url":"https://api.github.com/repos/communityshare/communityshare/contributors","subscribers_url":"https://api.github.com/repos/communityshare/communityshare/subscribers","subscription_url":"https://api.github.com/repos/communityshare/communityshare/subscription","commits_url":"https://api.github.com/repos/communityshare/communityshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/communityshare/communityshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/communityshare/communityshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/communityshare/communityshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/communityshare/communityshare/contents/{+path}","compare_url":"https://api.github.com/repos/communityshare/communityshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/communityshare/communityshare/merges","archive_url":"https://api.github.com/repos/communityshare/communityshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/communityshare/communityshare/downloads","issues_url":"https://api.github.com/repos/communityshare/communityshare/issues{/number}","pulls_url":"https://api.github.com/repos/communityshare/communityshare/pulls{/number}","milestones_url":"https://api.github.com/repos/communityshare/communityshare/milestones{/number}","notifications_url":"https://api.github.com/repos/communityshare/communityshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/communityshare/communityshare/labels{/name}","releases_url":"https://api.github.com/repos/communityshare/communityshare/releases{/id}","deployments_url":"https://api.github.com/repos/communityshare/communityshare/deployments","created_at":"2014-04-18T04:31:09Z","updated_at":"2016-10-05T05:39:05Z","pushed_at":"2016-10-17T01:42:03Z","git_url":"git://github.com/communityshare/communityshare.git","ssh_url":"git@github.com:communityshare/communityshare.git","clone_url":"https://github.com/communityshare/communityshare.git","svn_url":"https://github.com/communityshare/communityshare","homepage":null,"size":4381,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":50,"forks":12,"open_issues":50,"watchers":6,"default_branch":"master"}},"base":{"label":"communityshare:master","ref":"master","sha":"7c4079b527210078bacaa09abe968c97b3fb3baa","user":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"repo":{"id":18902595,"name":"communityshare","full_name":"communityshare/communityshare","owner":{"login":"communityshare","id":17582499,"avatar_url":"https://avatars.githubusercontent.com/u/17582499?v=3","gravatar_id":"","url":"https://api.github.com/users/communityshare","html_url":"https://github.com/communityshare","followers_url":"https://api.github.com/users/communityshare/followers","following_url":"https://api.github.com/users/communityshare/following{/other_user}","gists_url":"https://api.github.com/users/communityshare/gists{/gist_id}","starred_url":"https://api.github.com/users/communityshare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/communityshare/subscriptions","organizations_url":"https://api.github.com/users/communityshare/orgs","repos_url":"https://api.github.com/users/communityshare/repos","events_url":"https://api.github.com/users/communityshare/events{/privacy}","received_events_url":"https://api.github.com/users/communityshare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/communityshare/communityshare","description":"An online network connecting educators with community partners","fork":false,"url":"https://api.github.com/repos/communityshare/communityshare","forks_url":"https://api.github.com/repos/communityshare/communityshare/forks","keys_url":"https://api.github.com/repos/communityshare/communityshare/keys{/key_id}","collaborators_url":"https://api.github.com/repos/communityshare/communityshare/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/communityshare/communityshare/teams","hooks_url":"https://api.github.com/repos/communityshare/communityshare/hooks","issue_events_url":"https://api.github.com/repos/communityshare/communityshare/issues/events{/number}","events_url":"https://api.github.com/repos/communityshare/communityshare/events","assignees_url":"https://api.github.com/repos/communityshare/communityshare/assignees{/user}","branches_url":"https://api.github.com/repos/communityshare/communityshare/branches{/branch}","tags_url":"https://api.github.com/repos/communityshare/communityshare/tags","blobs_url":"https://api.github.com/repos/communityshare/communityshare/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/communityshare/communityshare/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/communityshare/communityshare/git/refs{/sha}","trees_url":"https://api.github.com/repos/communityshare/communityshare/git/trees{/sha}","statuses_url":"https://api.github.com/repos/communityshare/communityshare/statuses/{sha}","languages_url":"https://api.github.com/repos/communityshare/communityshare/languages","stargazers_url":"https://api.github.com/repos/communityshare/communityshare/stargazers","contributors_url":"https://api.github.com/repos/communityshare/communityshare/contributors","subscribers_url":"https://api.github.com/repos/communityshare/communityshare/subscribers","subscription_url":"https://api.github.com/repos/communityshare/communityshare/subscription","commits_url":"https://api.github.com/repos/communityshare/communityshare/commits{/sha}","git_commits_url":"https://api.github.com/repos/communityshare/communityshare/git/commits{/sha}","comments_url":"https://api.github.com/repos/communityshare/communityshare/comments{/number}","issue_comment_url":"https://api.github.com/repos/communityshare/communityshare/issues/comments{/number}","contents_url":"https://api.github.com/repos/communityshare/communityshare/contents/{+path}","compare_url":"https://api.github.com/repos/communityshare/communityshare/compare/{base}...{head}","merges_url":"https://api.github.com/repos/communityshare/communityshare/merges","archive_url":"https://api.github.com/repos/communityshare/communityshare/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/communityshare/communityshare/downloads","issues_url":"https://api.github.com/repos/communityshare/communityshare/issues{/number}","pulls_url":"https://api.github.com/repos/communityshare/communityshare/pulls{/number}","milestones_url":"https://api.github.com/repos/communityshare/communityshare/milestones{/number}","notifications_url":"https://api.github.com/repos/communityshare/communityshare/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/communityshare/communityshare/labels{/name}","releases_url":"https://api.github.com/repos/communityshare/communityshare/releases{/id}","deployments_url":"https://api.github.com/repos/communityshare/communityshare/deployments","created_at":"2014-04-18T04:31:09Z","updated_at":"2016-10-05T05:39:05Z","pushed_at":"2016-10-17T01:42:03Z","git_url":"git://github.com/communityshare/communityshare.git","ssh_url":"git@github.com:communityshare/communityshare.git","clone_url":"https://github.com/communityshare/communityshare.git","svn_url":"https://github.com/communityshare/communityshare","homepage":null,"size":4381,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":50,"forks":12,"open_issues":50,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/220"},"html":{"href":"https://github.com/communityshare/communityshare/pull/220"},"issue":{"href":"https://api.github.com/repos/communityshare/communityshare/issues/220"},"comments":{"href":"https://api.github.com/repos/communityshare/communityshare/issues/220/comments"},"review_comments":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/220/comments"},"review_comment":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/communityshare/communityshare/pulls/220/commits"},"statuses":{"href":"https://api.github.com/repos/communityshare/communityshare/statuses/dd78fdf7b1b794dcaea2166d0565caaf7449a810"}}}}
{"actor":{"display_login":"houndci-bot"}}