Skip to content

Commit 9b08d61

Browse files
authored
Update MultiAuthCollector.php
1 parent 0a6659a commit 9b08d61

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/DataCollector/MultiAuthCollector.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use DebugBar\DataCollector\DataCollector;
66
use DebugBar\DataCollector\Renderable;
7+
use Illuminate\Auth\Recaller;
78
use Illuminate\Auth\SessionGuard;
89
use Illuminate\Contracts\Auth\Authenticatable;
910
use Illuminate\Contracts\Auth\Guard;
@@ -21,6 +22,7 @@ class MultiAuthCollector extends DataCollector implements Renderable
2122

2223
/** @var \Illuminate\Auth\AuthManager */
2324
protected $auth;
25+
2426
/** @var bool */
2527
protected $showName = false;
2628

@@ -51,9 +53,9 @@ public function collect()
5153
$data = [];
5254
$names = '';
5355

54-
foreach($this->guards as $guardName) {
56+
foreach($this->guards as $guardName => $config) {
5557
try {
56-
$user = $this->resolveUser($this->auth->guard($guardName));
58+
$user = $this->resolveUser($this->auth->guard($guardName), $config);
5759
} catch (\Exception $e) {
5860
continue;
5961
}
@@ -76,19 +78,26 @@ public function collect()
7678
return $data;
7779
}
7880

79-
private function resolveUser(Guard $guard)
81+
private function resolveUser(Guard $guard, array $config)
8082
{
8183
// if we're logging in using remember token
8284
// then we must resolve user „manually”
8385
// to prevent csrf token regeneration
84-
86+
8587
$recaller = $guard instanceof SessionGuard
8688
? new Recaller($guard->getRequest()->cookies->get($guard->getRecallerName()))
8789
: null;
8890

89-
return !is_null($recaller) && !is_null($user = $this->provider->retrieveByToken(
90-
$recaller->id(), $recaller->token()
91-
)) ? $user : $guard->user();
91+
if ($recaller !== null) {
92+
$provider = $this->auth->createUserProvider($config['provider']);
93+
94+
$user = $provider->retrieveByToken($recaller->id(), $recaller->token());
95+
if ($user) {
96+
return $user;
97+
}
98+
}
99+
100+
return $guard->user();
92101
}
93102

94103
/**

0 commit comments

Comments
 (0)