Skip to content

Commit

Permalink
Update a variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
elnurvl committed May 24, 2024
1 parent f652da6 commit 2bcb9b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ActingAsKeycloakUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

trait ActingAsKeycloakUser
{
protected array $payload = [];
protected array $jwtPayload = [];

public function actingAsKeycloakUser($user = null, $payload = []): self
{
$principal = Config::get('keycloak.token_principal_attribute');
if (!$user && !isset($payload[$principal]) && !isset($this->payload[$principal])) {
if (!$user && !isset($payload[$principal]) && !isset($this->jwtPayload[$principal])) {
Config::set('keycloak.load_user_from_database', false);
}

Expand Down Expand Up @@ -51,7 +51,7 @@ public function generateKeycloakToken($user = null, $payload = []): string
'exp' => $exp,
$principal => config('keycloak.preferred_username'),
'resource_access' => $resourceAccess,
], $this->payload, $payload);
], $this->jwtPayload, $payload);

if ($user) {
$payload[$principal] = is_string($user) ? $user : $user->$credential;
Expand Down
4 changes: 2 additions & 2 deletions tests/AuthenticateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ public function test_acting_as_keycloak_user_trait_with_custom_payload(string $s
$arg = [];

if ($scope === 'class') {
$this->payload = $payload;
$this->jwtPayload = $payload;
} else {
$this->payload['sub'] = 'should_be_overwritten';
$this->jwtPayload['sub'] = 'should_be_overwritten';
$arg = $payload;
}

Expand Down

0 comments on commit 2bcb9b9

Please sign in to comment.