{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/jetpack/pulls/comments/53220517","id":53220517,"diff_hunk":"@@ -37,61 +37,45 @@ function authorize() {\n \t\t\t$jetpack = $this->get_jetpack();\n \t\t\t$role = $jetpack->translate_current_user_to_role();\n \n-\t\t\tif ( !$role ) {\n-\t\t\t\tJetpack::state( 'error', 'no_role' );\n-\t\t\t\tbreak;\n+\t\t\tif ( ! $role ) {\n+\t\t\t\treturn new Jetpack_Error( 'no_role', 'Invalid request.', 400 );\n \t\t\t}\n \n \t\t\t$cap = $jetpack->translate_role_to_cap( $role );\n \t\t\tif ( !$cap ) {\n-\t\t\t\tJetpack::state( 'error', 'no_cap' );\n-\t\t\t\tbreak;\n+\t\t\t\treturn new Jetpack_Error( 'no_cap', 'Invalid request.', 400 );\n \t\t\t}\n \n-\t\t\t$this->check_admin_referer( \"jetpack-authorize_{$role}_{$redirect}\" );\n-\n-\t\t\tif ( !empty( $data['error'] ) ) {\n-\t\t\t\tJetpack::state( 'error', $data['error'] );\n-\t\t\t\tbreak;\n+\t\t\tif ( ! empty( $data['error'] ) ) {\n+\t\t\t\treturn new Jetpack_Error( $data['error'], 'Error included in the request.', 400 );\n \t\t\t}\n \n-\t\t\tif ( empty( $data['state'] ) ) {\n-\t\t\t\tJetpack::state( 'error', 'no_state' );\n-\t\t\t\tbreak;\n+\t\t\tif ( ! isset( $data['state'] ) ) {\n+\t\t\t\treturn new Jetpack_Error( 'no_state', 'Request must include state.', 400 );\n \t\t\t}\n \n-\t\t\tif ( !ctype_digit( $data['state'] ) ) {\n-\t\t\t\tJetpack::state( 'error', 'invalid_state' );\n-\t\t\t\tbreak;\n+\t\t\tif ( ! ctype_digit( $data['state'] ) ) {\n+\t\t\t\treturn new Jetpack_Error( $data['error'], 'State must be an integer.', 400 );\n \t\t\t}\n \n \t\t\t$current_user_id = get_current_user_id();\n \t\t\tif ( $current_user_id != $data['state'] ) {\n-\t\t\t\tJetpack::state( 'error', 'wrong_state' );\n-\t\t\t\tbreak;\n+\t\t\t\treturn new Jetpack_Error( 'wrong_state', 'State does not match current user.', 400 );\n \t\t\t}\n \n \t\t\tif ( empty( $data['code'] ) ) {\n-\t\t\t\tJetpack::state( 'error', 'no_code' );\n-\t\t\t\tbreak;\n+\t\t\t\treturn new Jetpack_Error( 'no_code', 'Request must include an authorization code.', 400 );\n \t\t\t}\n \n \t\t\t$token = $this->get_token( $data );\n \n \t\t\tif ( is_wp_error( $token ) ) {\n-\t\t\t\tif ( $error = $token->get_error_code() )\n-\t\t\t\t\tJetpack::state( 'error', $error );\n-\t\t\t\telse\n-\t\t\t\t\tJetpack::state( 'error', 'invalid_token' );\n-\n-\t\t\t\tJetpack::state( 'error_description', $token->get_error_message() );\n-\n-\t\t\t\tbreak;\n+\t\t\t\t$code = $token->get_error_code() || 'invalid_token';","path":"class.jetpack-client-server.php","position":76,"original_position":76,"commit_id":"ee5d2807e0931018a15f7a6eadd784e8caee4866","original_commit_id":"ee5d2807e0931018a15f7a6eadd784e8caee4866","user":{"login":"roccotripaldi","id":2694219,"avatar_url":"https://avatars.githubusercontent.com/u/2694219?v=3","gravatar_id":"","url":"https://api.github.com/users/roccotripaldi","html_url":"https://github.com/roccotripaldi","followers_url":"https://api.github.com/users/roccotripaldi/followers","following_url":"https://api.github.com/users/roccotripaldi/following{/other_user}","gists_url":"https://api.github.com/users/roccotripaldi/gists{/gist_id}","starred_url":"https://api.github.com/users/roccotripaldi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roccotripaldi/subscriptions","organizations_url":"https://api.github.com/users/roccotripaldi/orgs","repos_url":"https://api.github.com/users/roccotripaldi/repos","events_url":"https://api.github.com/users/roccotripaldi/events{/privacy}","received_events_url":"https://api.github.com/users/roccotripaldi/received_events","type":"User","site_admin":false},"body":"good catch. there was javascript bleedover","created_at":"2016-02-17T19:50:01Z","updated_at":"2016-02-17T19:50:01Z","html_url":"https://github.com/Automattic/jetpack/pull/3364#discussion_r53220517","pull_request_url":"https://api.github.com/repos/Automattic/jetpack/pulls/3364","_links":{"self":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/comments/53220517"},"html":{"href":"https://github.com/Automattic/jetpack/pull/3364#discussion_r53220517"},"pull_request":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/3364"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/jetpack/pulls/3364","id":57772220,"html_url":"https://github.com/Automattic/jetpack/pull/3364","diff_url":"https://github.com/Automattic/jetpack/pull/3364.diff","patch_url":"https://github.com/Automattic/jetpack/pull/3364.patch","issue_url":"https://api.github.com/repos/Automattic/jetpack/issues/3364","number":3364,"state":"open","locked":false,"title":"Remote Authorize","user":{"login":"roccotripaldi","id":2694219,"avatar_url":"https://avatars.githubusercontent.com/u/2694219?v=3","gravatar_id":"","url":"https://api.github.com/users/roccotripaldi","html_url":"https://github.com/roccotripaldi","followers_url":"https://api.github.com/users/roccotripaldi/followers","following_url":"https://api.github.com/users/roccotripaldi/following{/other_user}","gists_url":"https://api.github.com/users/roccotripaldi/gists{/gist_id}","starred_url":"https://api.github.com/users/roccotripaldi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roccotripaldi/subscriptions","organizations_url":"https://api.github.com/users/roccotripaldi/orgs","repos_url":"https://api.github.com/users/roccotripaldi/repos","events_url":"https://api.github.com/users/roccotripaldi/events{/privacy}","received_events_url":"https://api.github.com/users/roccotripaldi/received_events","type":"User","site_admin":false},"body":"This PR adds a new xmlrpc method `remoteAuthorize` to allow folks to authorize their site entirely from WordPress.com\r\n\r\nThis PR adds provisions to `Jetpack_Client_Server->authorize()` so that it can handle both remote requests, and local, internal requests. The `authorize` method will still be used by folks who are simply linking their account to an already connected site.\r\n\r\nPing me for testing instructions.","created_at":"2016-01-31T16:02:52Z","updated_at":"2016-02-17T19:50:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d51f0569c99b128b98071f7cdb8191472f5886a8","assignee":{"login":"roccotripaldi","id":2694219,"avatar_url":"https://avatars.githubusercontent.com/u/2694219?v=3","gravatar_id":"","url":"https://api.github.com/users/roccotripaldi","html_url":"https://github.com/roccotripaldi","followers_url":"https://api.github.com/users/roccotripaldi/followers","following_url":"https://api.github.com/users/roccotripaldi/following{/other_user}","gists_url":"https://api.github.com/users/roccotripaldi/gists{/gist_id}","starred_url":"https://api.github.com/users/roccotripaldi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roccotripaldi/subscriptions","organizations_url":"https://api.github.com/users/roccotripaldi/orgs","repos_url":"https://api.github.com/users/roccotripaldi/repos","events_url":"https://api.github.com/users/roccotripaldi/events{/privacy}","received_events_url":"https://api.github.com/users/roccotripaldi/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Automattic/jetpack/pulls/3364/commits","review_comments_url":"https://api.github.com/repos/Automattic/jetpack/pulls/3364/comments","review_comment_url":"https://api.github.com/repos/Automattic/jetpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/jetpack/issues/3364/comments","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/ee5d2807e0931018a15f7a6eadd784e8caee4866","head":{"label":"Automattic:add/connect-jp-remotely","ref":"add/connect-jp-remotely","sha":"ee5d2807e0931018a15f7a6eadd784e8caee4866","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":15231212,"name":"jetpack","full_name":"Automattic/jetpack","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/jetpack","description":"Your WordPress, streamlined.","fork":false,"url":"https://api.github.com/repos/Automattic/jetpack","forks_url":"https://api.github.com/repos/Automattic/jetpack/forks","keys_url":"https://api.github.com/repos/Automattic/jetpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/jetpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/jetpack/teams","hooks_url":"https://api.github.com/repos/Automattic/jetpack/hooks","issue_events_url":"https://api.github.com/repos/Automattic/jetpack/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/jetpack/events","assignees_url":"https://api.github.com/repos/Automattic/jetpack/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/jetpack/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/jetpack/tags","blobs_url":"https://api.github.com/repos/Automattic/jetpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/jetpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/jetpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/jetpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/jetpack/languages","stargazers_url":"https://api.github.com/repos/Automattic/jetpack/stargazers","contributors_url":"https://api.github.com/repos/Automattic/jetpack/contributors","subscribers_url":"https://api.github.com/repos/Automattic/jetpack/subscribers","subscription_url":"https://api.github.com/repos/Automattic/jetpack/subscription","commits_url":"https://api.github.com/repos/Automattic/jetpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/jetpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/jetpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/jetpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/jetpack/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/jetpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/jetpack/merges","archive_url":"https://api.github.com/repos/Automattic/jetpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/jetpack/downloads","issues_url":"https://api.github.com/repos/Automattic/jetpack/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/jetpack/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/jetpack/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/jetpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/jetpack/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/jetpack/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/jetpack/deployments","created_at":"2013-12-16T16:43:01Z","updated_at":"2016-02-17T00:09:22Z","pushed_at":"2016-02-17T18:28:39Z","git_url":"git://github.com/Automattic/jetpack.git","ssh_url":"git@github.com:Automattic/jetpack.git","clone_url":"https://github.com/Automattic/jetpack.git","svn_url":"https://github.com/Automattic/jetpack","homepage":"http://jetpack.me","size":73454,"stargazers_count":502,"watchers_count":502,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":304,"mirror_url":null,"open_issues_count":646,"forks":304,"open_issues":646,"watchers":502,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"83ba3a3352c27258170e71cf6e36487bb9d45af5","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":15231212,"name":"jetpack","full_name":"Automattic/jetpack","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/jetpack","description":"Your WordPress, streamlined.","fork":false,"url":"https://api.github.com/repos/Automattic/jetpack","forks_url":"https://api.github.com/repos/Automattic/jetpack/forks","keys_url":"https://api.github.com/repos/Automattic/jetpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/jetpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/jetpack/teams","hooks_url":"https://api.github.com/repos/Automattic/jetpack/hooks","issue_events_url":"https://api.github.com/repos/Automattic/jetpack/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/jetpack/events","assignees_url":"https://api.github.com/repos/Automattic/jetpack/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/jetpack/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/jetpack/tags","blobs_url":"https://api.github.com/repos/Automattic/jetpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/jetpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/jetpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/jetpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/jetpack/languages","stargazers_url":"https://api.github.com/repos/Automattic/jetpack/stargazers","contributors_url":"https://api.github.com/repos/Automattic/jetpack/contributors","subscribers_url":"https://api.github.com/repos/Automattic/jetpack/subscribers","subscription_url":"https://api.github.com/repos/Automattic/jetpack/subscription","commits_url":"https://api.github.com/repos/Automattic/jetpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/jetpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/jetpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/jetpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/jetpack/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/jetpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/jetpack/merges","archive_url":"https://api.github.com/repos/Automattic/jetpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/jetpack/downloads","issues_url":"https://api.github.com/repos/Automattic/jetpack/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/jetpack/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/jetpack/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/jetpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/jetpack/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/jetpack/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/jetpack/deployments","created_at":"2013-12-16T16:43:01Z","updated_at":"2016-02-17T00:09:22Z","pushed_at":"2016-02-17T18:28:39Z","git_url":"git://github.com/Automattic/jetpack.git","ssh_url":"git@github.com:Automattic/jetpack.git","clone_url":"https://github.com/Automattic/jetpack.git","svn_url":"https://github.com/Automattic/jetpack","homepage":"http://jetpack.me","size":73454,"stargazers_count":502,"watchers_count":502,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":304,"mirror_url":null,"open_issues_count":646,"forks":304,"open_issues":646,"watchers":502,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/3364"},"html":{"href":"https://github.com/Automattic/jetpack/pull/3364"},"issue":{"href":"https://api.github.com/repos/Automattic/jetpack/issues/3364"},"comments":{"href":"https://api.github.com/repos/Automattic/jetpack/issues/3364/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/3364/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/3364/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/jetpack/statuses/ee5d2807e0931018a15f7a6eadd784e8caee4866"}}}}