• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / EDD_API::validate_request() – Validate the API request

You appear to be a bot. Output may be restricted

Description

Validate the API request

Checks for the user's public key and token against the secret key

Usage

$bool = EDD_API::validate_request();

Parameters

Returns

bool

Source

File name: easy-digital-downloads/includes/api/class-edd-api.php
Lines:

1 to 48 of 48
  private function validate_request() {
    global $wp_query;

    $this->override = false;

    // Make sure we have both user and api key
    if ( ! empty( $wp_query->query_vars['edd-api'] ) && ( ! $this->is_public_query() || ! empty( $wp_query->query_vars['token'] ) ) ) {

      if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
        $this->missing_auth();
        return  false;
      }

      // Auth was provided, include the upgrade routine so we can use the fallback api checks
      require_once EDD_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';

      // Retrieve the user by public API key and ensure they exist
      if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {

        $this->invalid_key();
        return  false;

      } else {

        $token  = urldecode( $wp_query->query_vars['token'] );
        $secret = $this->get_user_secret_key( $user );
        $public = urldecode( $wp_query->query_vars['key'] );

        // Verify that if user has secret key or not.
        if ( ! $secret ) {
          $this->invalid_auth();
        }

        $valid = $this->check_keys( $secret, $public, $token );
        if ( $valid ) {
          $this->is_valid_request = true;
        } else {
          $this->invalid_auth();
          return  false;
        }

      }
    } elseif ( ! empty( $wp_query->query_vars['edd-api'] ) && $this->is_public_query() ) {
      $this->is_valid_request = true;
      $wp_query->set( 'key', 'public' );
    }

  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 12th September 2021

Primary Sidebar

Information

Function name: EDD_API::validate_request
Class ref: EDD_API
Plugin ref: Easy Digital Downloads
Version: 2.11.6
Sourcefile: includes/api/class-edd-api.php
File ref: includes/api/class-edd-api.php
Deprecated?: No
API Letters: A,E,R,V

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites