From 7a4f6ba026de308ff8dfcdce2e1ba2ec086affe8 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Sat, 2 Nov 2019 13:57:51 -0500 Subject: [PATCH 1/2] Correctly clear user data on reset also before authentication. --- includes/Core/Util/Migration_1_0_0.php | 24 +++++++++++++++++++++--- includes/Core/Util/Reset.php | 23 ++++++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/includes/Core/Util/Migration_1_0_0.php b/includes/Core/Util/Migration_1_0_0.php index 8a1c59c6e10..ea325d0c842 100644 --- a/includes/Core/Util/Migration_1_0_0.php +++ b/includes/Core/Util/Migration_1_0_0.php @@ -13,6 +13,7 @@ use Google\Site_Kit\Context; use Google\Site_Kit\Core\Authentication\Authentication; use Google\Site_Kit\Core\Authentication\Clients\OAuth_Client; +use Google\Site_Kit\Core\Authentication\Verification_Tag; use Google\Site_Kit\Core\Authentication\Credentials; use Google\Site_Kit\Core\Storage\Encrypted_Options; use Google\Site_Kit\Core\Storage\Options; @@ -116,9 +117,26 @@ private function disconnect_users() { $key_prefix = $this->context->is_network_mode() ? '' : $wpdb->get_blog_prefix(); $user_ids = ( new \WP_User_Query( array( - 'fields' => 'id', - 'meta_key' => $key_prefix . OAuth_Client::OPTION_ACCESS_TOKEN, - 'compare' => 'EXISTS', + 'fields' => 'id', + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => $key_prefix . Verification_Tag::OPTION, + 'compare' => 'EXISTS', + ), + array( + 'key' => $key_prefix . OAuth_Client::OPTION_ACCESS_TOKEN, + 'compare' => 'EXISTS', + ), + array( + 'key' => $key_prefix . OAuth_Client::OPTION_PROXY_ACCESS_CODE, + 'compare' => 'EXISTS', + ), + array( + 'key' => $key_prefix . OAuth_Client::OPTION_ERROR_CODE, + 'compare' => 'EXISTS', + ), + ), ) ) )->get_results(); diff --git a/includes/Core/Util/Reset.php b/includes/Core/Util/Reset.php index 8ebbdff4179..47bd408dc8c 100644 --- a/includes/Core/Util/Reset.php +++ b/includes/Core/Util/Reset.php @@ -143,9 +143,26 @@ private function delete_all_user_metas() { $key_prefix = $this->context->is_network_mode() ? '' : $wpdb->get_blog_prefix(); $user_query = new \WP_User_Query( array( - 'fields' => 'id', - 'meta_key' => $key_prefix . OAuth_Client::OPTION_ACCESS_TOKEN, - 'compare' => 'EXISTS', + 'fields' => 'id', + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => $key_prefix . Verification_Tag::OPTION, + 'compare' => 'EXISTS', + ), + array( + 'key' => $key_prefix . OAuth_Client::OPTION_ACCESS_TOKEN, + 'compare' => 'EXISTS', + ), + array( + 'key' => $key_prefix . OAuth_Client::OPTION_PROXY_ACCESS_CODE, + 'compare' => 'EXISTS', + ), + array( + 'key' => $key_prefix . OAuth_Client::OPTION_ERROR_CODE, + 'compare' => 'EXISTS', + ), + ), ) ); From 24fc7aadbd9d21b1201e451813587c7a581d3266 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Sat, 2 Nov 2019 15:13:27 -0500 Subject: [PATCH 2/2] Fix typo in README.md. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa26fcd379e..759d42d5df0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Learn more: [https://sitekit.withgoogle.com](https://sitekit.withgoogle.com) ## Contributing -Any kind of contributions to Site Kit by Google are welcome. Head over to the [Contributor Handhook](https://github.com/google/site-kit-wp/wiki) to get started, or directly to the [Engineering set up quickstart](https://github.com/google/site-kit-wp/wiki/Engineering#set-up-site-kit-project) to set up Sit Kit locally. :wink: +Any kind of contributions to Site Kit by Google are welcome. Head over to the [Contributor Handhook](https://github.com/google/site-kit-wp/wiki) to get started, or directly to the [Engineering set up quickstart](https://github.com/google/site-kit-wp/wiki/Engineering#set-up-site-kit-project) to set up Site Kit locally. :wink: ## Requirements