Skip to content

Commit 522cb24

Browse files
authored
Merge pull request #40 from wp-graphql/bug/#39-conflict-with-the-events-calendar
Conflicts with "The Events Calendar" also active
2 parents 86aadf3 + 42fff3a commit 522cb24

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Auth.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ protected static function authenticate_user( $username, $password ) {
364364
* @param (int|bool) $user Logged User ID
365365
*
366366
* @return mixed|false|\WP_User
367+
* @throws \Exception
367368
*/
368369
public static function filter_determine_current_user( $user ) {
369370

@@ -377,7 +378,7 @@ public static function filter_determine_current_user( $user ) {
377378
/**
378379
* If no token was generated, return the existing value for the $user
379380
*/
380-
if ( empty( $token ) ) {
381+
if ( empty( $token ) || is_wp_error( $token ) ) {
381382

382383
/**
383384
* Return the user that was passed in to the filter
@@ -397,7 +398,6 @@ public static function filter_determine_current_user( $user ) {
397398

398399
}
399400

400-
401401
/**
402402
* Everything is ok, return the user ID stored in the token
403403
*/
@@ -488,6 +488,7 @@ public static function unrevoke_user_secret( int $user_id ) {
488488

489489
}
490490

491+
491492
protected static function set_status( $status_code ) {
492493
add_filter( 'graphql_response_status_code', function() use ( $status_code ) {
493494
return $status_code;
@@ -560,7 +561,7 @@ public static function validate_token( $token = null, $refresh = false ) {
560561
/**
561562
* The Token is decoded now validate the iss
562563
*/
563-
if ( get_bloginfo( 'url' ) !== $token->iss ) {
564+
if ( ! isset( $token->iss ) || get_bloginfo( 'url' ) !== $token->iss ) {
564565
throw new \Exception( __( 'The iss do not match with this server', 'wp-graphql-jwt-authentication' ) );
565566
}
566567

vendor/composer/ClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function isClassMapAuthoritative()
279279
*/
280280
public function setApcuPrefix($apcuPrefix)
281281
{
282-
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
282+
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283283
}
284284

285285
/**
@@ -377,7 +377,7 @@ private function findFileWithExtension($class, $ext)
377377
$subPath = $class;
378378
while (false !== $lastPos = strrpos($subPath, '\\')) {
379379
$subPath = substr($subPath, 0, $lastPos);
380-
$search = $subPath.'\\';
380+
$search = $subPath . '\\';
381381
if (isset($this->prefixDirsPsr4[$search])) {
382382
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383383
foreach ($this->prefixDirsPsr4[$search] as $dir) {

wp-graphql-jwt-authentication.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ private function includes() {
163163
*/
164164
private static function init() {
165165

166-
167166
/**
168167
* Initialize the GraphQL fields for managing tokens
169168
*/
@@ -175,7 +174,7 @@ private static function init() {
175174
add_filter( 'determine_current_user', [
176175
'\WPGraphQL\JWT_Authentication\Auth',
177176
'filter_determine_current_user'
178-
], 10, 1 );
177+
], 99, 1 );
179178

180179
/**
181180
* Filter the rootMutation fields
@@ -202,4 +201,4 @@ function init() {
202201
return JWT_Authentication::instance();
203202
}
204203

205-
add_action( 'plugins_loaded', '\WPGraphQL\JWT_Authentication\init' );
204+
add_action( 'plugins_loaded', '\WPGraphQL\JWT_Authentication\init', 1 );

0 commit comments

Comments
 (0)