Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
build
coverage.xml
.phpunit.result.cache
.idea
11 changes: 11 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@

return [

/*
|--------------------------------------------------------------------------
| JWT Authentication Key
|--------------------------------------------------------------------------
|
| You can define a specific key to return user data from the JWT
|
*/

'identifier' => env('JWT_IDENTIFIER', 'sub'),

/*
|--------------------------------------------------------------------------
| JWT Authentication Secret
Expand Down
2 changes: 1 addition & 1 deletion src/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ protected function getClaimsArray(JWTSubject $subject)
protected function getClaimsForSubject(JWTSubject $subject)
{
return array_merge([
'sub' => $subject->getJWTIdentifier(),
config('jwt.identifier') => $subject->getJWTIdentifier(),
], $this->lockSubject ? ['prv' => $this->hashSubjectModel($subject)] : []);
}

Expand Down
2 changes: 1 addition & 1 deletion src/JWTAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function attempt(array $credentials)
*/
public function authenticate()
{
$id = $this->getPayload()->get('sub');
$id = $this->getPayload()->get(config('jwt.identifier'));

if (! $this->auth->byId($id)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/JWTGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function user()
($payload = $this->jwt->check(true)) &&
$this->validateSubject()
) {
return $this->user = $this->provider->retrieveById($payload['sub']);
return $this->user = $this->provider->retrieveById($payload[config('jwt.identifier')]);
}
}

Expand Down