Skip to content

Commit

Permalink
Only revoke token if no or invalid refresh token.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Nov 12, 2019
1 parent 8c10dec commit 20d711b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/Core/Authentication/Clients/OAuth_Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ function( $cache_key, $access_token ) {
public function refresh_token() {
$refresh_token = $this->get_refresh_token();
if ( empty( $refresh_token ) ) {
$this->revoke_token();
$this->user_options->set( self::OPTION_ERROR_CODE, 'refresh_token_not_exist' );
return;
}

// Stop if google_client not initialized yet.
Expand All @@ -257,7 +259,9 @@ public function refresh_token() {
$error_code = $e->getMessage();
}
// Revoke and delete user connection data if the refresh token is invalid or expired.
$this->revoke_token();
if ( 'invalid_grant' === $error_code ) {
$this->revoke_token();
}
$this->user_options->set( self::OPTION_ERROR_CODE, $error_code );
return;
}
Expand Down

0 comments on commit 20d711b

Please sign in to comment.