Skip to content

Commit 7438697

Browse files
committed
Correctly handle tokens with missing clients
As a side-effect of changing the meta key, there may be leftover tokens which now have an invalid client attached.
1 parent d942cf8 commit 7438697

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

inc/admin/profile/namespace.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ function bootstrap() {
2626
*/
2727
function render_profile_section( WP_User $user ) {
2828
$tokens = Access_Token::get_for_user( $user );
29+
$tokens = array_filter( $tokens, function ( Access_Token $token ) {
30+
return (bool) $token->get_client();
31+
});
32+
2933
?>
3034
<h2><?php _e( 'Authorized Applications', 'oauth2' ) ?></h2>
3135
<?php if ( ! empty( $tokens ) ) : ?>

inc/authentication/namespace.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ 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+
$client = $token->get_client();
120121
$is_querying_token = false;
121122

122-
if ( empty( $token ) ) {
123+
if ( empty( $token ) || empty( $client ) ) {
123124
$oauth2_error = create_invalid_token_error( $token_value );
124125
return $user;
125126
}

0 commit comments

Comments
 (0)