Skip to content

[13.x] Allow setting the client with Passport::actingAs()#1876

Merged
taylorotwell merged 1 commit intolaravel:13.xfrom
axlon:acting-as
Dec 15, 2025
Merged

[13.x] Allow setting the client with Passport::actingAs()#1876
taylorotwell merged 1 commit intolaravel:13.xfrom
axlon:acting-as

Conversation

@axlon
Copy link
Contributor

@axlon axlon commented Dec 15, 2025

Currently it is not possible to set the client that the token belongs to when using Passport::actingAs(...), this PR changes that. Also added extra assertions to check that the mocked token contains the expected properties.

These changes should be fully backwards compatible


Passport::actingAs(new User());
$client = new Client(['id' => 'client-1234']);
$user = (new User())->forceFill(['id' => 1234]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force filling here is necessary, as the model is guarded. I tried to change as little as possible

@taylorotwell taylorotwell merged commit de00e47 into laravel:13.x Dec 15, 2025
11 checks passed
@axlon axlon deleted the acting-as branch February 26, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants