Skip to content

Commit eb00006

Browse files
authored
Merge pull request #273 from renatonascalves/jwt-filter
Changing how we verify the JWT plugin
2 parents ab6b03a + 07bb75e commit eb00006

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

includes/class-jwt-auth-schema-filters.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
namespace WPGraphQL\WooCommerce;
1111

1212
use GraphQL\Error\UserError;
13-
use GraphQL\Type\Definition\ResolveInfo;
14-
use WPGraphQL\AppContext;
15-
use WPGraphQL\Model\User;
1613
use WPGraphQL\WooCommerce\Model\Customer;
1714
/**
1815
* Class JWT_Auth_Schema_Filters
@@ -22,8 +19,8 @@ class JWT_Auth_Schema_Filters {
2219
* Register filters
2320
*/
2421
public static function add_filters() {
25-
// Confirm WPGraphQL JWT Authentication is install and activated.
26-
if ( defined( 'WPGRAPHQL_JWT_AUTHENTICATION_VERSION' ) ) {
22+
// Confirm WPGraphQL JWT Authentication is installed.
23+
if ( \class_exists( '\WPGraphQL\JWT_Authentication\Auth') ) {
2724
add_filter( 'graphql_jwt_user_types', array( __CLASS__, 'add_customer_to_jwt_user_types' ), 10 );
2825
add_filter( 'graphql_registerCustomerPayload_fields', array( __CLASS__, 'add_jwt_output_fields' ), 10, 3 );
2926
add_filter( 'graphql_updateCustomerPayload_fields', array( __CLASS__, 'add_jwt_output_fields' ), 10, 3 );
@@ -34,11 +31,10 @@ public static function add_filters() {
3431
/**
3532
* Adds Customer type to the JWT User type list.
3633
*
37-
* @param array $types JWT User types.
38-
*
34+
* @param array $types JWT User types.
3935
* @return array
4036
*/
41-
public static function add_customer_to_jwt_user_types( $types ) {
37+
public static function add_customer_to_jwt_user_types( array $types ) {
4238
$types[] = 'Customer';
4339

4440
return $types;
@@ -50,8 +46,9 @@ public static function add_customer_to_jwt_user_types( $types ) {
5046
* @param array $fields Mutation output field definitions.
5147
* @param \WPGraphQL\Type\WPInputObjectType $object The WPInputObjectType the fields are be added to.
5248
* @param \WPGraphQL\Registry\TypeRegistry $type_registry TypeRegistry instance.
49+
* @return array
5350
*/
54-
public static function add_jwt_output_fields( $fields, $object, $type_registry ) {
51+
public static function add_jwt_output_fields( $fields, $object, $type_registry ): array {
5552
$fields = array_merge(
5653
$fields,
5754
array(
@@ -90,7 +87,7 @@ public static function add_jwt_output_fields( $fields, $object, $type_registry )
9087
}
9188

9289
/**
93-
* Adds "customer" field to "login" mutation payload
90+
* Adds "customer" field to "login" mutation payload.
9491
*/
9592
public static function add_customer_to_login_payload() {
9693
register_graphql_field(

0 commit comments

Comments
 (0)