Skip to content

Commit ef93304

Browse files
n0fbarryvdh
authored andcommitted
Validate $recaller in MultiAuthCollector.php (barryvdh#633)
1 parent dcc6350 commit ef93304

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/DataCollector/MultiAuthCollector.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
namespace Barryvdh\Debugbar\DataCollector;
4-
use Illuminate\Contracts\Auth\Guard;
4+
use Illuminate\Auth\Recaller;
55
use Illuminate\Auth\SessionGuard;
6+
use Illuminate\Contracts\Auth\Guard;
67

78
/**
89
* Collector for Laravel's Auth provider
@@ -58,17 +59,17 @@ private function resolveUser(Guard $guard)
5859
// then we must resolve user „manually”
5960
// to prevent csrf token regeneration
6061

61-
$usingSession = $guard instanceof SessionGuard;
62-
$recaller = $usingSession ? $guard->getRequest()->cookies->get($guard->getRecallerName()) : null;
62+
$recaller = $guard instanceof SessionGuard
63+
? new Recaller($guard->getRequest()->cookies->get($guard->getRecallerName()))
64+
: null;
6365

64-
if($usingSession && !is_null($recaller)) {
65-
list($id, $token) = explode('|', $recaller);
66-
return $guard->getProvider()->retrieveByToken($id, $token);
66+
if (!is_null($recaller) && $recaller->valid()) {
67+
return $guard->getProvider()->retrieveByToken($recaller->id(), $recaller->token());
6768
} else {
6869
return $guard->user();
6970
}
7071
}
71-
72+
7273
/**
7374
* @{inheritDoc}
7475
*/

0 commit comments

Comments
 (0)