Skip to content

Commit

Permalink
Remove breakage on user-agent changing
Browse files Browse the repository at this point in the history
  • Loading branch information
tractorcow committed Apr 29, 2019
1 parent 2548b73 commit f2b6ecb
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/Authentication/JWTAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ public function validateToken(string $token, HTTPrequest $request): array
}

// Find local record for this token
$record = $this->findTokenRecord($parsedToken, $request);
/** @var JWTRecord $record */
$record = JWTRecord::get()->byID($parsedToken->getClaim('rid'));
if (!$record) {
return [null, TokenStatusEnum::STATUS_INVALID];
}
Expand Down Expand Up @@ -336,23 +337,6 @@ protected function parseToken(string $token): ?Token
return $verified ? $parsedToken : null;
}

/**
* Given a parsed Token, find the matching JWTRecord dataobject
*
* @param Token $parsedToken
* @param HTTPRequest $request
* @return JWTRecord|null
*/
protected function findTokenRecord(Token $parsedToken, HTTPrequest $request): ?JWTRecord
{
$userAgent = $request->getHeader('User-Agent');
/** @var JWTRecord $record */
$record = JWTRecord::get()
->filter(['UserAgent' => $userAgent])
->byID($parsedToken->getClaim('rid'));
return $record;
}

/**
* Determine if the given token is current, given the context of the current request
*
Expand Down

0 comments on commit f2b6ecb

Please sign in to comment.