| @@ -121,30 +121,8 @@ | ||
| 121 | 121 | if ( empty( $response['user']['api_key'] ) ) { |
| 122 | 122 | return $this->error( 'login_error', $response['message'] ?? __('Invalid API key.', 'templately'), 'login', 400 ); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $options = $this->utils( 'options' ); | |
| 126 | - $options->use_current_user( true ); | |
| 127 | - | |
| 128 | - try { | |
| 129 | - return $this->store_connection( $response, $global_signin, $_ip, $_site_url ); | |
| 130 | - } finally { | |
| 131 | - $options->use_current_user( false ); | |
| 132 | - } | |
| 133 | - } | |
| 134 | - | |
| 135 | - /** | |
| 136 | - * Persist an authenticated connection against the acting user. | |
| 137 | - * | |
| 138 | - * @param array $response Cloud response, already validated. | |
| 139 | - * @param bool $global_signin Whether the user asked to sign in globally. | |
| 140 | - * @param string $_ip Request IP, echoed back into the profile. | |
| 141 | - * @param string $_site_url Site URL, echoed back into the profile. | |
| 142 | - * | |
| 143 | - * @return array | |
| 144 | - */ | |
| 145 | - private function store_connection( $response, $global_signin, $_ip, $_site_url ) { | |
| 146 | - | |
| 147 | 125 | if ( $global_signin && ! Login::is_globally_signed() ) { |
| 148 | 126 | Options::set_global_login(); |
| 149 | 127 | } |
| 150 | 128 | |
| @@ -250,12 +228,8 @@ | ||
| 250 | 228 | if ( $global_user_id !== $this->utils( 'options' )->current_user_id() ) { |
| 251 | 229 | $global_user = $this->utils( 'options' )->get( 'user', false, $global_user_id ); |
| 252 | 230 | |
| 253 | 231 | if ( ! empty( $global_user ) ) { |
| 254 | - if ( is_array( $global_user ) ) { | |
| 255 | - unset( $global_user['api_key'] ); | |
| 256 | - } | |
| 257 | - | |
| 258 | 232 | $global_user['meta'] = $this->user_meta(); |
| 259 | 233 | } |
| 260 | 234 | } |
| 261 | 235 | |
| @@ -269,13 +243,8 @@ | ||
| 269 | 243 | |
| 270 | 244 | $_user = ( new static )->utils( 'options' )->get( 'user', null ); |
| 271 | 245 | |
| 272 | 246 | if ( ! is_null( $_user ) ) { |
| 273 | - // Profiles stored before 3.7.1 may still carry the cloud API key. | |
| 274 | - if ( is_array( $_user ) ) { | |
| 275 | - unset( $_user['api_key'] ); | |
| 276 | - } | |
| 277 | - | |
| 278 | 247 | $_user['meta'] = self::get_instance()->user_meta(); |
| 279 | 248 | } |
| 280 | 249 | |
| 281 | 250 | if ( empty( $_user ) ) { |
| @@ -308,5 +277,5 @@ | ||
| 308 | 277 | |
| 309 | 278 | public static function signed_as_global(): bool { |
| 310 | 279 | return rest_sanitize_boolean( ( new static )->utils( 'options' )->signed_as_global() ); |
| 311 | 280 | } |
| 312 | -} | |
| 281 | +} | |