Skip to content
Permalink
Browse files

Fix: compatibility fix for WC 2.4 SSL authentication

  • Loading branch information...
kilbot committed Aug 12, 2015
1 parent 4291e49 commit 525671b7613b20864366aebf426f14d07b37bfa4
Showing with 24 additions and 25 deletions.
  1. +23 −0 includes/class-wc-pos-api.php
  2. +0 −25 includes/class-wc-pos.php
  3. +1 −0 readme.txt
@@ -19,15 +19,38 @@ public function __construct() {
if( ! is_pos() )
return;
// remove wc api authentication
$wc_api_auth = WC()->api->authentication;
remove_filter( 'woocommerce_api_check_authentication', array( $wc_api_auth, 'authenticate' ), 0 );
// support for X-HTTP-Method-Override for WC < 2.4
if( version_compare( WC()->version, '2.4', '<' ) && isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']) ){
$_GET['_method'] = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
}
add_filter( 'woocommerce_api_check_authentication', array( $this, 'wc_api_authentication' ), 10, 0 );
add_filter( 'woocommerce_api_dispatch_args', array( $this, 'dispatch_args'), 10, 2 );
add_filter( 'woocommerce_api_query_args', array( $this, 'woocommerce_api_query_args' ), 10, 2 );
}
/**
* Bypass authentication for WC REST API
* @return WP_User object
*/
public function wc_api_authentication() {
global $current_user;
$user = $current_user;
if( ! user_can( $user->ID, 'access_woocommerce_pos' ) )
$user = new WP_Error(
'woocommerce_pos_authentication_error',
__( 'User not authorized to access WooCommerce POS', 'woocommerce-pos' ),
array( 'status' => 401 )
);
return $user;
}
/**
* @param $args
* @param $callback
@@ -22,7 +22,6 @@ public function __construct() {
}
add_action( 'init', array( $this, 'init' ) );
add_filter( 'woocommerce_api_check_authentication', array( $this, 'wc_api_authentication' ), 10, 2 );
add_action( 'woocommerce_api_loaded', array( $this, 'load_woocommerce_api_patches') );
do_action( 'woocommerce_pos_loaded' );
@@ -78,30 +77,6 @@ public function init() {
}
/**
* Bypass authentication for WC REST API
*
* @param $user
*
* @return WP_User object
*/
public function wc_api_authentication( $user, $wc_api ) {
if( is_pos() ) {
global $current_user;
$user = $current_user;
if( ! user_can( $user->ID, 'access_woocommerce_pos' ) )
$user = new WP_Error(
'woocommerce_pos_authentication_error',
__( 'User not authorized to access WooCommerce POS', 'woocommerce-pos' ),
array( 'status' => 401 )
);
}
return $user;
}
/**
*
*/
@@ -83,6 +83,7 @@ Bugs can be reported on the [WooCommerce POS GitHub repository](https://github.c
* Fix: variation display and select issues - commit [91c7ec1](https://github.com/kilbot/WooCommerce-POS/commit/91c7ec13e737f820d84feb7890d7b6d027a79792), [b3d6543](https://github.com/kilbot/WooCommerce-POS/commit/b3d6543b86140df62ff90f3a7b7e734d73ae59ab)
* Fix: variation barcode search for products in queue - commit [3fda531](https://github.com/kilbot/WooCommerce-POS/commit/3fda5317ef580f6b6d70e24ba235d2b7e69c5ee4)
* Fix: populate order addresses from customer id - commit [b86bc56](https://github.com/kilbot/WooCommerce-POS/commit/b86bc5650a2bf41d7744bf07cda34407e8fa3dd5)
* Fix: compatibility fix for WC 2.4 SSL authentication - commit []()
* Tweak: WP Admin CSS - commit [c5a38c7](https://github.com/kilbot/WooCommerce-POS/commit/c5a38c7f889a7788e3eaa633c28620d2e80ac2ee)

= 0.4.1 =

0 comments on commit 525671b

Please sign in to comment.
You can’t perform that action at this time.