Skip to content

Commit 95adbb7

Browse files
authored
use Auth::userResolver when resolving the authenticated user (#54382)
1 parent 33d61c4 commit 95adbb7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Illuminate/Container/Attributes/Authenticated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public function __construct(public ?string $guard = null)
2525
*/
2626
public static function resolve(self $attribute, Container $container)
2727
{
28-
return $container->make('auth')->guard($attribute->guard)->user();
28+
return call_user_func($container->make('auth')->userResolver(), $attribute->guard);
2929
}
3030
}

tests/Container/ContextualAttributeBindingTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public function testAuthedAttribute()
111111
$container = new Container;
112112
$container->singleton('auth', function () {
113113
$manager = m::mock(AuthManager::class);
114+
$manager->shouldReceive('userResolver')->andReturn(fn ($guard = null) => $manager->guard($guard)->user());
114115
$manager->shouldReceive('guard')->with('foo')->andReturnUsing(function () {
115116
$guard = m::mock(GuardContract::class);
116117
$guard->shouldReceive('user')->andReturn(m:mock(AuthenticatableContract::class));

0 commit comments

Comments
 (0)