Skip to content

Commit 4719877

Browse files
authored
Merge pull request #52 from WP-API/fix-fatal-on-missing-token
Check $token before using it
2 parents 988cb55 + 1c7513d commit 4719877

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

inc/authentication/namespace.php

+6
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ function attempt_authentication( $user = null ) {
117117
// Attempt to find the token.
118118
$is_querying_token = true;
119119
$token = Tokens\get_by_id( $token_value );
120+
if ( empty( $token ) ) {
121+
$is_querying_token = false;
122+
$oauth2_error = create_invalid_token_error( $token_value );
123+
return $user;
124+
}
125+
120126
$client = $token->get_client();
121127
$is_querying_token = false;
122128

0 commit comments

Comments
 (0)