summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-user-connect-endpoint.php')
-rw-r--r--plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-user-connect-endpoint.php9
1 files changed, 5 insertions, 4 deletions
diff --git a/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-user-connect-endpoint.php b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-user-connect-endpoint.php
index 366f5ff7..b88d0406 100644
--- a/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-user-connect-endpoint.php
+++ b/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-user-connect-endpoint.php
@@ -1,6 +1,7 @@
<?php
-use Automattic\Jetpack\Connection\Utils as Connection_Utils;
+use Automattic\Jetpack\Connection\Manager as Connection_Manager;
+use Automattic\Jetpack\Connection\Tokens;
class Jetpack_JSON_API_User_Connect_Endpoint extends Jetpack_JSON_API_Endpoint {
@@ -10,8 +11,8 @@ class Jetpack_JSON_API_User_Connect_Endpoint extends Jetpack_JSON_API_Endpoint {
private $user_token;
function result() {
- Connection_Utils::update_user_token( $this->user_id, sprintf( '%s.%d', $this->user_token, $this->user_id ), false );
- return array( 'success' => Jetpack::is_user_connected( $this->user_id ) );
+ ( new Tokens() )->update_user_token( $this->user_id, sprintf( '%s.%d', $this->user_token, $this->user_id ), false );
+ return array( 'success' => ( new Connection_Manager( 'jetpack' ) )->is_user_connected( $this->user_id ) );
}
function validate_input( $user_id ) {
@@ -20,7 +21,7 @@ class Jetpack_JSON_API_User_Connect_Endpoint extends Jetpack_JSON_API_Endpoint {
return new WP_Error( 'input_error', __( 'user_id is required', 'jetpack' ) );
}
$this->user_id = $user_id;
- if ( Jetpack::is_user_connected( $this->user_id ) ) {
+ if ( ( new Connection_Manager( 'jetpack' ) )->is_user_connected( $this->user_id ) ) {
return new WP_Error( 'user_already_connected', __( 'The user is already connected', 'jetpack' ) );
}
if ( ! isset( $input['user_token'] ) ) {