Skip to content

Commit

Permalink
Merge pull request #773 from google/fix/771-clear-verification-tokens…
Browse files Browse the repository at this point in the history
…-on-reset

Correctly clear user data on reset also before authentication
  • Loading branch information
felixarntz authored Nov 2, 2019
2 parents cb944a4 + 7a4f6ba commit 3341a4f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
24 changes: 21 additions & 3 deletions includes/Core/Util/Migration_1_0_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
23 changes: 20 additions & 3 deletions includes/Core/Util/Reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
),
)
);

Expand Down

0 comments on commit 3341a4f

Please sign in to comment.