-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update/split site user connection mgt my jetpack #41520
base: fix/my-jetpack-for-non-admins
Are you sure you want to change the base?
Update/split site user connection mgt my jetpack #41520
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Here's an open question @jeherve and @bindlegirl This PR moves an API endpoint from the Jetpack plugin to the connection package (connection/user). The endpoint in the package has a version check so that it won't double-register the endpoint if an older version of Jetpack has already registered it. But this raises the issue - if a standalone plugin using the newer version of My Jetpack and newer connection package is installed on a site with an older version of the Jetpack plugin, the way My Jetpack is going to expect the I've tested and can verify this behavior with the Jetpack Beta plugin. An alternative could be to register the endpoint in the connection package as a "new" endpoint with a different name - but that feels counterproductive. Any ideas for the best way forward here? |
Would skipping the version check and setting the override parameter to I haven't checked the differences in the updated endpoint just yet so I am throwing out that suggestion. |
@bindlegirl - that sounds like it would be a good option. I've overlooked the The new endpoint should be compatible if called from the older version of the Jetpack plugin, the old behavior and arguments are still present, the updated version just adds a new optional parameter and uses a new mapped capability to allow for unlinking of non-admins w/o a connection owner. |
What if the new endpoint were to have a different slug? We'd keep the old Jetpack-only endpoint around, but stop using it in new versions of My Jetpack. Then in a few versions, we could get rid of the Jetpack-only version entirely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the changes thoroughly with both the Jetpack main plugin and then again with a standalone plugin (I did Protect) and it all works as expected. I couldn't find any issues!
I do have one question about the user disconnection. Is a page reload required for this? Or could we update all the data on the screen async? You obviously know more about this flow than me so I assume there probably needs to be one for some reason, but wanted to bring it up just in case 😄
I left some comments. None major, but there are enough I think it warrants requesting changes 😄
{ isCurrentUserAdmin && | ||
connectedUser.currentUser?.isConnected && | ||
connectedUser.currentUser?.isMaster && ( | ||
<ManageConnectionActionCard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thought, yes I think that makes sense
onClick = () => null, | ||
link = '#', | ||
action, | ||
disabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have disabled be false
by default? I guess an omission leaving it null would most likely have the same behavior, I guess I just prefer explicit defaults 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I agree adding false is more clear 👍
*/ | ||
public static function unlink_user( $request ) { | ||
|
||
if ( ! isset( $request['linked'] ) || false !== $request['linked'] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not running into issues while testing, so I assume this works correctly. I'm just having a hard time understanding why the correct thing to do is return an error if the user is linked in this case 🤔
Wouldn't false !== $request['linked']
be true if the user is linked? Or am I misunderstanding the linked
parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of an odd parameter - if it's false
it means we want the user to be unlinked from what I understand. At least that's the effect. It doesn't have to do with checking that the current user is connected already or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for explaining! It is a very confusingly named param 😅 But it makes sense why it works correctly
|
||
// Allow admins to force a disconnect by passing the "force" parameter | ||
// This allows an admin to disconnect themselves | ||
if ( isset( $request['force'] ) && false !== $request['force'] && current_user_can( 'manage_options' ) && ( new Manager( 'jetpack' ) )->disconnect_user_force( get_current_user_id() ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm finding it a bit weird to have the actual disconnect function be invoked in the if statement checks. I guess it works correctly, and I can see the benefit of a simpler hierarchy of if statements but I don't think it's best practices and, imo, it makes it harder to read and understand what's happening 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree on this one - since the function returns a boolean, I think It's OK to run in as part of the if
statement, given that the return value of the function is intended to be a rest_response object or WP_Error.
The first couple of checks in the if statement are used to bail early before trying the disconnect.
The second else if
condition follows the same pattern to determine if the disconnect operation worked or failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a big enough issue to push back too hard, so I won't block approval for it again 😄 However I just wanted to share an article I found that explains, in better words than I could, why I am on the other side of this debate: https://www.teamten.com/lawrence/programming/keep-if-clauses-side-effect-free.html
@@ -63,7 +63,7 @@ const ConnectionListItem: ConnectionListItemType = ( { | |||
<div className={ styles[ 'list-item' ] }> | |||
<Text className={ clsx( styles[ 'list-item-text' ], statusStyles ) }> | |||
{ icon && <Icon icon={ icon } /> } | |||
{ text } | |||
<span>{ text }</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this for some sort of styling change? I don't see any CSS changes related to this so I just wanted to make sure it wasn't leftover from a previous implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was to appease the tests 😅 They were having trouble locating an element with the specified text on the screen, adding a wrapping element helped the matching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 😆
__( 'Connected as %1$s (Owner).', 'jetpack-my-jetpack' ), | ||
userConnectionData.currentUser?.wpcomUser?.display_name | ||
/* translators: %1$s is user name, %2$s is the user email */ | ||
__( 'Connected as %1$s (Owner) ( %2$s ).', 'jetpack-my-jetpack' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not intentional, I'll remove those spaces!
In addition to the comments in my review, I just noticed it looks like a few of the connection tests are not passing |
I discussed this case with @fgiannar, and she shared some previous PRs where endpoints were moved to connection package #16384 and #20440 I think it would be best to follow the same procedure we used there (moving the endpoint, deprecating methods). The workings of the It seems the safest route would be to make sure the UI can support the edge case where the old endpoint is registered last. |
Another suggestion is to do the endpoint changes in a separate PR. |
Thanks for the review @CodeyGuyDylan
Sort of. After the user is disconnected, we can update the connection state on the front end but the red bubble alerts and the evaluation of "broken" modules that required a user connection are currently pulled from the initial react state - which is loaded in from PHP. The page "works" without reloading, the connection area still shows the user as disconnected, but there are a few things that are not fully up to date - card statuses, alert messages, etc. I do like the experience better without the reload, but I am in favor of accepting the tradeoff of reloading in order to update the product and alert information for now. Once we re-fetch that data async and aren't pulling it from the initial react state then the reload could be removed here. |
…d error handling in case the user disconnect fails
That makes sense, I guess it'd be quite a bit more work to make sure everything is in sync after that (if it's even possible to get all of it). I think it's okay in this case 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you have one linting issue that's causing a test to fail, but other than that I think the changes look great, LGTM
'jetpack-connection-js' | ||
); | ||
} | ||
setUnlinkError( errorMessage ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice addition with the error message 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it all and it works well. Nice job!
Proposed changes:
Does this pull request change what data or activity we track or use?
Yes, this PR adds one new click event for when someone clicks to disconnect their user account:
jetpack_manage_connection_dialog_disconnect_user_click
Testing instructions:
To test this PR fully, you will need a test site with a non admin user and an admin user along with two separate WPCOM accounts that you can use to connect these users individually.
Start by connecting both the admin and non-admin users with their respective WPCOM accounts
As the admin user, navigate to My Jetpack (Jetpack in the admin left nav)
Your connection area should look like below, showing both your wpcom username and email:
![Screenshot 2025-02-04 at 4 04 29 PM](https://private-user-images.githubusercontent.com/18016357/409737187-0208a83a-d338-4f7a-b3ac-d17778ad8a01.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3MzcxODctMDIwOGE4M2EtZDMzOC00ZjdhLWIzYWMtZDE3Nzc4YWQ4YTAxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg4OWYwZDlmZTcwZDk5OTlhNGJhNTM3YTgzZDIwMWU2OTVkZDAxNWI4NjUyM2MxZTNlZWQwMTFlODY5YTkwZjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.7KSb1fCjc82L0DLTS0oMF4jrEf3nCFTID3NMo90x44A)
Now, check My Jetpack as the non-admin user. You should see your wpcom username and email as well as the local username of the connected site owner
![Screenshot 2025-02-04 at 4 06 42 PM](https://private-user-images.githubusercontent.com/18016357/409737505-605ce911-54f8-431d-8837-0abc6bb38f04.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3Mzc1MDUtNjA1Y2U5MTEtNTRmOC00MzFkLTg4MzctMGFiYzZiYjM4ZjA0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVhN2RmYTkzZTJjZTBiMmM5MjJmNGMwYWIxZDQwN2VjMGFmZGY3MTRjNzIwZDMwYTNhYzdjZmFkOGM4YWQ2NzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.cZLTmcXboHBEJaYqLy4wDDT1dMR3bLIxXvkf75rARnQ)
As the non-admin user, click "Manage" next to the connection icons. You should get the manage connection dialog with only one option - disconnecting your user account:
![Screenshot 2025-02-04 at 4 07 42 PM](https://private-user-images.githubusercontent.com/18016357/409737854-c27a5baa-1b5f-43f5-a74b-5555aae4f73c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3Mzc4NTQtYzI3YTViYWEtMWI1Zi00M2Y1LWE3NGItNTU1NWFhZTRmNzNjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ0NzE0MjYwOTU0NWJhYjQzNGQwNDJmNzBiODYwYzk3NjZhNDJkNDUyYzdiNzYwNjgwMGJmNWY3NGY4ZWQ0NWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.lJczN7hR9G73RS5uCbpKVrYRRCNV6tQeUMUlfc2xyhk)
Click on "Disconnect My User account". The modal should show in a "pending" state while the user disconnects and then close itself. The page will also reload after the modal closes
![Screenshot 2025-02-04 at 4 10 56 PM](https://private-user-images.githubusercontent.com/18016357/409738166-e785b0ac-87c6-4920-8bb5-7b45d094c6a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3MzgxNjYtZTc4NWIwYWMtODdjNi00OTIwLThiYjUtN2I0NWQwOTRjNmEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI2ZjNkNjc4YTNlMWMwY2M3NjgxYzNhM2YxZThkMGZiNTQ3OWQ0YzdmOTMzMGU5OTNkMzQ2N2QyNzI0M2M0ZWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.6zo-xj-V120FaQvXzj4QraVq8iuS0lGJ8fjsvG4V5Wk)
Now that the non-admin user has been disconnected, the connection area should no longer show the "Manage" link next to the connection icons. In place of the user information, there should be a prompt to sign back in.
![Screenshot 2025-02-04 at 4 11 07 PM](https://private-user-images.githubusercontent.com/18016357/409738379-8991e51a-d511-4417-a6c4-913b12303386.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3MzgzNzktODk5MWU1MWEtZDUxMS00NDE3LWE2YzQtOTEzYjEyMzAzMzg2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA3MzRjN2YwNjIyYmEwMDZhOWI0MzliY2ExODc2OGFjMWM4NDQ3NmVjYTIyOGNmZWRlMTZlM2YwNTc1ZjhiNDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.kG4yRz3VDqxm6qMbPJLAThIuEipzXs3vb66YkDmpY38)
Test that you can sign in again as the non-admin user. Leave the non-admin user connected for further testing later on.
Now, return to the site as the admin user
Click on "Manage" next to the connection icons to open the connection management modal
The admin user should have three options (assuming they are also the connection owner) - transfer ownership, disconnect user account, and Disconnect Jetpack
![Screenshot 2025-02-04 at 4 19 07 PM](https://private-user-images.githubusercontent.com/18016357/409742598-e36da6cc-8af2-4c1c-a0ad-8361a270936f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3NDI1OTgtZTM2ZGE2Y2MtOGFmMi00YzFjLWEwYWQtODM2MWEyNzA5MzZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVkNzZlNTE3YzRiZTMwNzM0M2ZjMDg3ZTgzZTc1OGVlNDRkZDk5MWFhZWUzOTI3YWQ4MzdjMzIwZTM5ODU2Y2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.bQ5uo7v2Ru7uEh_7AmgX8WE5JTWWNvMVR0s5d3-uiSU)
Go ahead and disconnect the admin user. The page will reload after disconnection. After reload, the connection area should look something like this (the message can differ depending on whether you had products that were previously relying on the user connection to work)
![Screenshot 2025-02-04 at 4 19 28 PM](https://private-user-images.githubusercontent.com/18016357/409739680-51c7ec66-31f6-467c-a61c-08f9d942c65f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3Mzk2ODAtNTFjN2VjNjYtMzFmNi00NjdjLWE2MWMtMDhmOWQ5NDJjNjVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ2MGVlODljZmY0OTY2N2MxNzAyYTY1YzhkMTEwMzZlZjFjMmExMDA2NjFhNWUwZTBjZjgxMzllZmVkZTZmMGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Ej-WG0l_C42Qd98RHrM8Laf4cMq_Q0loY8I10G1wmNo)
If you click "Manage" again as the admin user, there should only be one option, to Disconnect Jetpack. This will disconnect the site from Jetpack (removes the site token)
![Screenshot 2025-02-04 at 4 19 51 PM](https://private-user-images.githubusercontent.com/18016357/409742831-8e8c9211-27ee-4912-8846-59a1c18b07a6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3NDI4MzEtOGU4YzkyMTEtMjdlZS00OTEyLTg4NDYtNTlhMWMxOGIwN2E2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcwNDgxZGM5YjE3OTJmNTc5Mjg4M2ZkMmVjODZhNDgzM2NhZWY0Y2Q4NGU4Mjc4ZmE1Mzc4YWM3YzY5YTk0NDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.6jVCkVZdZhUOMubdak9LdeLUAA3gSju9UlGN_lY6sG0)
Go ahead and disconnect the site from Jetpack. The connection area should prompt for re-connection of the site after disconnection:
![Screenshot 2025-02-04 at 4 20 52 PM](https://private-user-images.githubusercontent.com/18016357/409740036-de4357b4-e712-499b-81b5-5de22ec5019c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3NDAwMzYtZGU0MzU3YjQtZTcxMi00OTliLTgxYjUtNWRlMjJlYzUwMTljLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVlZmIzZTViMzliMDNjN2NkM2RkNzY0Mzc5YzYxNjE5OGVkODIxNGFhNTBlMzRkMmE2OTE4ZmI0Y2MzNjcxM2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.TmZLu-gQwQEmjVkZhy5wpAqH-QeDZqrPpNLiNQd5GYA)
Re-connect the site by clicking "Connect"
After the site connects, before re-connecting the admin user, visit the site as the non-admin user (who we should have left in a connected state in our previous test)
For the connected non-admin, now that the admin user and connection owner has disconnected, the connection area should no longer show the connection owner as being "also connected"
![Screenshot 2025-02-04 at 4 27 48 PM](https://private-user-images.githubusercontent.com/18016357/409741679-c57fcc22-2cec-46e1-970f-2da8de4d6ea5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3NDE2NzktYzU3ZmNjMjItMmNlYy00NmUxLTk3MGYtMmRhOGRlNGQ2ZWE1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThmOTcyYzY5YjAyZDk0MTkwMWQ0NTNjNWFlY2YzZTUwNDQxZjkxYTIwNTYyNWNkNzg1NmQ0MGM2MzIzMmUwYzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.l5Fuo-eXxcXWMyw78sXhXIONT51xJSaFZiv9RVqZpZs)
The option to "Manage" and disconnect the non-admin user is still present - make sure that you can still disconnect the non-admin user here with no admin connection owner.
After the non-admin user disconnects, without the presence of a connection owner, the connection area should now indicate that an admin needs to connect before they can sign in again
![Screenshot 2025-02-04 at 4 30 17 PM](https://private-user-images.githubusercontent.com/18016357/409742103-486eade4-d4f4-4288-89e7-5236e3b2351d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxOTEwNTQsIm5iZiI6MTczOTE5MDc1NCwicGF0aCI6Ii8xODAxNjM1Ny80MDk3NDIxMDMtNDg2ZWFkZTQtZDRmNC00Mjg4LTg5ZTctNTIzNmUzYjIzNTFkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDEyMzIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU0ODgxODc5NmM0ZjhlZThhYTgyZDk1MzMzMjAwN2U0Y2QyYTEyMDgzNjI1ZDFmNmM4OTgxYzM4ZWJiNzhlYTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.kzstiAHSCIt46YRcGrN14BlQ468IbwAx48ndGNyooYI)
Fiddle around with the different users and connection states and confirm that the copy and messaging makes sense for different states and roles.
Testing with an older version of the Jetpack plugin
Because this PR moves the
/connection/user
API endpoint from the Jetpack plugin to the connection package, there are scenarios where both the Jetpack plugin and the connection package will register the same endpoint. To mitigate this, this PR makes sure the API endpoint registration for the connection package runs later than the registration for the Jetpack plugin by running on priority11
for therest_api_init
hook.To test that the new endpoint it still called when an older version of Jetpack is active: