Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ public function fromUser(JWTSubject $user)
public function refresh($forceForever = false, $resetClaims = false)
{
$this->requireToken();
$this->manager->setRefreshFlow();

return $this->manager->customClaims($this->getCustomClaims())
->refresh($this->token, $forceForever, $resetClaims)
->get();
if (!$user = $this->authenticate()) {
throw new UnauthorizedHttpException('jwt-auth', 'User not found');
}
return $this->manager->customClaims($this->getClaimsArray($user))
->refresh($this->token, $forceForever, $resetClaims)
->get();
}

/**
Expand Down Expand Up @@ -181,7 +185,7 @@ public function getToken()
*/
public function parseToken()
{
if (! $token = $this->parser->parseToken()) {
if (!$token = $this->parser->parseToken()) {
throw new JWTException('The token could not be parsed from the request');
}

Expand Down Expand Up @@ -246,7 +250,7 @@ protected function getClaimsArray(JWTSubject $subject)
return array_merge(
$this->getClaimsForSubject($subject),
$subject->getJWTCustomClaims(), // custom claims from JWTSubject method
$this->customClaims // custom claims from inline setter
$this->customClaims// custom claims from inline setter
);
}

Expand Down Expand Up @@ -327,7 +331,7 @@ public function unsetToken()
*/
protected function requireToken()
{
if (! $this->token) {
if (!$this->token) {
throw new JWTException('A token is required');
}
}
Expand Down