{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/5337","repository_url":"https://api.github.com/repos/Automattic/wp-calypso","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/5337/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/5337/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/5337/events","html_url":"https://github.com/Automattic/wp-calypso/pull/5337","id":154277090,"number":5337,"title":"Jetpack connect: Allow linked accounts","user":{"login":"johnHackworth","id":1554855,"avatar_url":"https://avatars.githubusercontent.com/u/1554855?v=3","gravatar_id":"","url":"https://api.github.com/users/johnHackworth","html_url":"https://github.com/johnHackworth","followers_url":"https://api.github.com/users/johnHackworth/followers","following_url":"https://api.github.com/users/johnHackworth/following{/other_user}","gists_url":"https://api.github.com/users/johnHackworth/gists{/gist_id}","starred_url":"https://api.github.com/users/johnHackworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnHackworth/subscriptions","organizations_url":"https://api.github.com/users/johnHackworth/orgs","repos_url":"https://api.github.com/users/johnHackworth/repos","events_url":"https://api.github.com/users/johnHackworth/events{/privacy}","received_events_url":"https://api.github.com/users/johnHackworth/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/Jetpack","name":"Jetpack","color":"006b75"},{"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Status]%20Needs%20Review","name":"[Status] Needs Review","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"johnHackworth","id":1554855,"avatar_url":"https://avatars.githubusercontent.com/u/1554855?v=3","gravatar_id":"","url":"https://api.github.com/users/johnHackworth","html_url":"https://github.com/johnHackworth","followers_url":"https://api.github.com/users/johnHackworth/followers","following_url":"https://api.github.com/users/johnHackworth/following{/other_user}","gists_url":"https://api.github.com/users/johnHackworth/gists{/gist_id}","starred_url":"https://api.github.com/users/johnHackworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnHackworth/subscriptions","organizations_url":"https://api.github.com/users/johnHackworth/orgs","repos_url":"https://api.github.com/users/johnHackworth/repos","events_url":"https://api.github.com/users/johnHackworth/events{/privacy}","received_events_url":"https://api.github.com/users/johnHackworth/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/59","html_url":"https://github.com/Automattic/wp-calypso/milestones/Jetpack-Connect%20m1","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/59/labels","id":1603137,"number":59,"title":"Jetpack-Connect m1","description":"","creator":{"login":"johnHackworth","id":1554855,"avatar_url":"https://avatars.githubusercontent.com/u/1554855?v=3","gravatar_id":"","url":"https://api.github.com/users/johnHackworth","html_url":"https://github.com/johnHackworth","followers_url":"https://api.github.com/users/johnHackworth/followers","following_url":"https://api.github.com/users/johnHackworth/following{/other_user}","gists_url":"https://api.github.com/users/johnHackworth/gists{/gist_id}","starred_url":"https://api.github.com/users/johnHackworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnHackworth/subscriptions","organizations_url":"https://api.github.com/users/johnHackworth/orgs","repos_url":"https://api.github.com/users/johnHackworth/repos","events_url":"https://api.github.com/users/johnHackworth/events{/privacy}","received_events_url":"https://api.github.com/users/johnHackworth/received_events","type":"User","site_admin":false},"open_issues":39,"closed_issues":52,"state":"open","created_at":"2016-02-24T15:32:10Z","updated_at":"2016-05-12T15:56:15Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-05-11T15:47:26Z","updated_at":"2016-05-12T22:07:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/5337","html_url":"https://github.com/Automattic/wp-calypso/pull/5337","diff_url":"https://github.com/Automattic/wp-calypso/pull/5337.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/5337.patch"},"body":"This PR removes the 'already connected' check in the first step of jetpack connect and defers that logic to the authorization step.\r\n\r\nUntil know, if a site was already connected to .com, in anyway, we didn't allow the user to go further the first step of jetpack connect. that way we didn't allow to connect secondary accounts.\r\n\r\nWith this PR, that restriction is lifted. Once the user enters an url and we do the roundtrip to their wp-admin, `authorize-form` will look if the site is already on the users sites list and will look for an additional parameter added by jetpack that indicates if the site is already connected or not (until know, jetpack would show an error instead of redirecting user back to calypso anyways in that case). This are the combinations that can happen:\r\n\r\n- Site not in sites-list, no 'already_authorized' param => normal authorization process\r\n- Site already in sites-list => directly to the last step of jetpack-connect (plans?) (since this .com user already have this site connected, we don't need to do anything)\r\n- Site not in sites-list, existent 'already_authorized' param => The user/site are already connected to a different WordPress.com account, so we warn the user about it and give them a link to their wp-admin to fix it:\r\n![image](https://cloud.githubusercontent.com/assets/1554855/15187000/92264ea0-179f-11e6-8587-190e7edc71f5.png)\r\n\r\n\r\nHow to test\r\n========\r\n\r\n1. You need a jetpack site with a jetpack running https://github.com/Automattic/jetpack/pull/3788\r\n2. Go to http://calypso.localhost:3000/jetpack/connect and connect a site that you already have connected with this same .com user. You should be taken directly to the last step of jetpack connect (the link to the plans page, right now)\r\n3. Login with a different .com user and try to connect the same site/user that you already connected in 2) . You should see the warning telling you that the site is already connected to other use and a button linking you to your wp-admin\r\n4. Login in your 3rd party site with a different user (remember to use one that has a automattic.com email address) and connect the site using http://calypso.localhost:3000/jetpack/connect . Everything should work fine, even if another user is already connected\r\n\r\nping @roccotripaldi @rickybanister "},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/218900226","html_url":"https://github.com/Automattic/wp-calypso/pull/5337#issuecomment-218900226","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/5337","id":218900226,"user":{"login":"johnHackworth","id":1554855,"avatar_url":"https://avatars.githubusercontent.com/u/1554855?v=3","gravatar_id":"","url":"https://api.github.com/users/johnHackworth","html_url":"https://github.com/johnHackworth","followers_url":"https://api.github.com/users/johnHackworth/followers","following_url":"https://api.github.com/users/johnHackworth/following{/other_user}","gists_url":"https://api.github.com/users/johnHackworth/gists{/gist_id}","starred_url":"https://api.github.com/users/johnHackworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnHackworth/subscriptions","organizations_url":"https://api.github.com/users/johnHackworth/orgs","repos_url":"https://api.github.com/users/johnHackworth/repos","events_url":"https://api.github.com/users/johnHackworth/events{/privacy}","received_events_url":"https://api.github.com/users/johnHackworth/received_events","type":"User","site_admin":false},"created_at":"2016-05-12T22:07:48Z","updated_at":"2016-05-12T22:07:48Z","body":"@rickybanister  this is what happens when you try to connect an user that is already connected to other .com user. If I'm not wrong, each .org user can only be connected to a .com user. Until now, if you tried to connect a site/user that already have an active connection (with a different .com user than the one you are logged at the moment), you got an 'Already connected' error message in jetpack (in your wp-admin). This PR moves that error message to calypso."}}