예제 #1
0
 /**
  * Saves the authorization code.
  */
 public function save_auth_code()
 {
     if (!$this->valid_nonce()) {
         wp_die('0');
     }
     // Validate the authorization.
     $service = $this->get_service();
     $authorization_code = filter_input(INPUT_POST, 'authorization');
     $is_authorization_valid = WPSEO_GSC_Settings::validate_authorization($authorization_code, $service->get_client());
     if (!$is_authorization_valid) {
         wp_die('0');
     }
     $this->get_profiles();
 }
예제 #2
0
 /**
  * Catch the authentication post
  */
 private function catch_authentication_post()
 {
     $gsc_values = filter_input(INPUT_POST, 'gsc', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
     // Catch the authorization code POST.
     if (!empty($gsc_values['authorization_code']) && wp_verify_nonce($gsc_values['gsc_nonce'], 'wpseo-gsc_nonce')) {
         if (!WPSEO_GSC_Settings::validate_authorization(trim($gsc_values['authorization_code']), $this->service->get_client())) {
             $this->add_notification(__('Incorrect Google Authorization Code.', 'wordpress-seo'), 'error');
         }
         // Redirect user to prevent a post resubmission which causes an oauth error.
         wp_redirect(admin_url('admin.php') . '?page=' . esc_attr(filter_input(INPUT_GET, 'page')) . '&tab=settings');
         exit;
     }
 }