Automattic\WooCommerce\Internal\PushNotifications\Controllers
PushNotificationRestController::authorize
Validates the JWT from the Authorization header, falling back to the token query parameter on hosts that strip the header before it reaches PHP (see {@see InternalNotificationDispatcher::TOKEN_QUERY_PARAM}).
Method of the class: PushNotificationRestController{}
No Hooks.
Returns
true|WP_Error.
Usage
$PushNotificationRestController = new PushNotificationRestController(); $PushNotificationRestController->authorize( $request );
- $request(WP_REST_Request) (required)
- The request object.
Changelog
| Since 10.7.0 | Introduced. |
PushNotificationRestController::authorize() PushNotificationRestController::authorize code WC 11.3.0
public function authorize( WP_REST_Request $request ) {
$reason = $this->find_authorization_failure( $request );
if ( null === $reason ) {
return true;
}
$this->log_authorization_failure( $request, $reason );
return new WP_Error(
'woocommerce_rest_unauthorized',
self::AUTH_FAILURE_MESSAGES[ $reason ],
array( 'status' => WP_Http::UNAUTHORIZED )
);
}