-
Notifications
You must be signed in to change notification settings - Fork 813
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
Deleting the connection owner? Think again (or transfer ownership.) #13322
Conversation
528adf4
to
e6e3f84
Compare
* @param string The capability of the user | ||
* @return array Array of WP_User objects if found. | ||
*/ | ||
public function get_connected_users( $capability = 'any' ) { |
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.
Happy to break these new methods out into their own PR if it makes it easier.
This is an automated check which relies on |
@@ -933,7 +933,7 @@ public function test_change_owner() { | |||
|
|||
// Create a user and set it up as current. | |||
$user = $this->create_and_get_user(); | |||
$user->add_cap( 'jetpack_connect_user' ); | |||
$user->add_cap( 'jetpack_disconnect' ); |
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.
This was the wrong user cap to allow switching connection owner. Any user can connect_user, but not any user can own the connection.
a573984
to
79da062
Compare
wp_set_current_user( $user->ID ); | ||
|
||
// Mock site already registered | ||
Jetpack_Options::update_option( 'user_tokens', array( $user->ID => "honey.badger.$user->ID" ) ); | ||
|
||
// Attempt change, fail because not master user | ||
$response = $this->create_and_get_request( 'connection/owner', array( 'owner' => 999 ), 'POST' ); |
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.
The method now allows non-master users to use this endpoint.
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.
I like the idea; I think it'd be a great addition to the Users screen. 👍
dc993bb
to
d265ddb
Compare
@jeherve ready again. |
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.
This should be good to go like this! 👍
e4381bf
to
c19c357
Compare
* 7.7 changelog: initial set of changes * Changelog: add #13154 * Changelog: add #13134 * Changelog: add #12699 and many others * Changelog: add #13127 * Changelog: add #13167 * Changelog: add #13225 * Changelog: add #13179 * Changelog: add #13173 * Changelog: add #13232 * Changelog: add #13137 * Changelog: add #13172 * Changelog: add #13182 * Changelog: add #13200 * Changelog: add #13244 * Changelog: add #13267 * Changelog: add #13204 * changelog: add #13205 * Changelog: add #13183 * Changelog: add #13278 * Changelog: add #13162 * Changelog: add #13268 * Changelog: add #13286 * Changelog: add #13273 * Changelog: add #12474 * Changelog: add #13085 * Changelog: add #13266 * Changelog: add #13306 * Changelog: add #13311 * Changelog: add #13302 * Changelog: add #13196 * Changelog: add #12733 * Changelog: add #13261 * Changelog: add #13322 * Changelog: add #13333 * Changelog: add #13335
Changes proposed in this Pull Request:
/connection/owner
endpoint.What this PR is intentionally not doing, and will be done in other PRs:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
There's a lot.
Test changing connection owner to secondary Admin
User A
.User B
.Verify it worked
After you did the above, you should be able to verify it "worked" by doing the following things:
wp jetpack options get master_user
- should be User B's ID returned.Test when there are no other users connected
Since we're only able to transfer ownership to another connected user, we needed a case to handle if there were none! So, you should expect to see a lot of text and a button to connect if this is the case when you're trying to delete the connection owner. For this one, please verify:
General things to check/verify
Proposed changelog entry for your changes:
*General: Warn users that deleting the connection owner is going to break things.