| @@ -36,12 +36,9 @@ | ||
| 36 | 36 | public function google_auth_url() { |
| 37 | 37 | // Get redirect_to parameter from request if provided |
| 38 | 38 | $redirect_to = $this->get_param( 'redirect-to', '' ); |
| 39 | 39 | |
| 40 | - // Use client-provided current_url instead of HTTP_REFERER for reliability | |
| 41 | - $current_url = $this->get_param( 'current_url', '' ); | |
| 42 | - | |
| 43 | - $url = $this->http()->google_auth_url( $redirect_to, $current_url ); | |
| 40 | + $url = $this->http()->google_auth_url( $redirect_to ); | |
| 44 | 41 | return [ |
| 45 | 42 | 'status' => 'success', |
| 46 | 43 | 'url' => $url |
| 47 | 44 | ]; |
| @@ -121,30 +118,8 @@ | ||
| 121 | 118 | if ( empty( $response['user']['api_key'] ) ) { |
| 122 | 119 | return $this->error( 'login_error', $response['message'] ?? __('Invalid API key.', 'templately'), 'login', 400 ); |
| 123 | 120 | } |
| 124 | 121 | |
| 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 | 122 | if ( $global_signin && ! Login::is_globally_signed() ) { |
| 148 | 123 | Options::set_global_login(); |
| 149 | 124 | } |
| 150 | 125 | |
| @@ -250,12 +225,8 @@ | ||
| 250 | 225 | if ( $global_user_id !== $this->utils( 'options' )->current_user_id() ) { |
| 251 | 226 | $global_user = $this->utils( 'options' )->get( 'user', false, $global_user_id ); |
| 252 | 227 | |
| 253 | 228 | if ( ! empty( $global_user ) ) { |
| 254 | - if ( is_array( $global_user ) ) { | |
| 255 | - unset( $global_user['api_key'] ); | |
| 256 | - } | |
| 257 | - | |
| 258 | 229 | $global_user['meta'] = $this->user_meta(); |
| 259 | 230 | } |
| 260 | 231 | } |
| 261 | 232 | |
| @@ -269,13 +240,8 @@ | ||
| 269 | 240 | |
| 270 | 241 | $_user = ( new static )->utils( 'options' )->get( 'user', null ); |
| 271 | 242 | |
| 272 | 243 | 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 | 244 | $_user['meta'] = self::get_instance()->user_meta(); |
| 279 | 245 | } |
| 280 | 246 | |
| 281 | 247 | if ( empty( $_user ) ) { |
| @@ -308,5 +274,5 @@ | ||
| 308 | 274 | |
| 309 | 275 | public static function signed_as_global(): bool { |
| 310 | 276 | return rest_sanitize_boolean( ( new static )->utils( 'options' )->signed_as_global() ); |
| 311 | 277 | } |
| 312 | -} | |
| 278 | +} | |