Skip to content

Commit

Permalink
use Auth::userResolver when resolving the authenticated user (#54382)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopedra authored Jan 28, 2025
1 parent 33d61c4 commit 95adbb7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Container/Attributes/Authenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function __construct(public ?string $guard = null)
*/
public static function resolve(self $attribute, Container $container)
{
return $container->make('auth')->guard($attribute->guard)->user();
return call_user_func($container->make('auth')->userResolver(), $attribute->guard);
}
}
1 change: 1 addition & 0 deletions tests/Container/ContextualAttributeBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public function testAuthedAttribute()
$container = new Container;
$container->singleton('auth', function () {
$manager = m::mock(AuthManager::class);
$manager->shouldReceive('userResolver')->andReturn(fn ($guard = null) => $manager->guard($guard)->user());
$manager->shouldReceive('guard')->with('foo')->andReturnUsing(function () {
$guard = m::mock(GuardContract::class);
$guard->shouldReceive('user')->andReturn(m:mock(AuthenticatableContract::class));
Expand Down

0 comments on commit 95adbb7

Please sign in to comment.