| @@ 102-118 (lines=17) @@ | ||
| 99 | } |
|
| 100 | ||
| 101 | $response_body = json_decode( wp_remote_retrieve_body( $result ) ); |
|
| 102 | if ( is_bool( $response_body ) && $response_body ) { |
|
| 103 | return rest_ensure_response( |
|
| 104 | array( |
|
| 105 | 'code' => 'success', |
|
| 106 | 'message' => __( 'Video meta updated successfully.', 'jetpack' ), |
|
| 107 | 'data' => 200, |
|
| 108 | ) |
|
| 109 | ); |
|
| 110 | } else { |
|
| 111 | return rest_ensure_response( |
|
| 112 | new WP_Error( |
|
| 113 | $response_body->code, |
|
| 114 | $response_body->message, |
|
| 115 | $response_body->data |
|
| 116 | ) |
|
| 117 | ); |
|
| 118 | } |
|
| 119 | } |
|
| 120 | } |
|
| 121 | ||
| @@ 715-722 (lines=8) @@ | ||
| 712 | $user = get_user_by( 'id', (int) $user_data->external_user_id ); |
|
| 713 | if ( $user ) { |
|
| 714 | $expected_id = get_user_meta( $user->ID, 'wpcom_user_id', true ); |
|
| 715 | if ( $expected_id && $expected_id != $user_data->ID ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 716 | $error = new WP_Error( 'expected_wpcom_user', __( 'Something got a little mixed up and an unexpected WordPress.com user logged in.', 'jetpack' ) ); |
|
| 717 | ||
| 718 | /** This filter is documented in core/src/wp-includes/pluggable.php */ |
|
| 719 | do_action( 'wp_login_failed', $user_data->login, $error ); |
|
| 720 | add_filter( 'login_message', array( 'Jetpack_SSO_Notices', 'error_invalid_response_data' ) ); // @todo Need to have a better notice. This is only for the sake of testing the validation. |
|
| 721 | return; |
|
| 722 | } |
|
| 723 | update_user_meta( $user->ID, 'wpcom_user_id', $user_data->ID ); |
|
| 724 | } |
|
| 725 | } |
|