File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 11<?php
22
33namespace Barryvdh \Debugbar \DataCollector ;
4+ use Illuminate \Contracts \Auth \Guard ;
5+ use Illuminate \Auth \SessionGuard ;
46
57/**
68 * Collector for Laravel's Auth provider
@@ -30,8 +32,10 @@ public function collect()
3032 $ names = '' ;
3133
3234 foreach ($ this ->guards as $ guardName ) {
33- $ user = $ this ->auth ->guard ($ guardName )->user ();
35+ $ user = $ this ->resolveUser ($ this ->auth ->guard ($ guardName ));
36+
3437 $ data ['guards ' ][$ guardName ] = $ this ->getUserInformation ($ user );
38+
3539 if (!is_null ($ user )) {
3640 $ names .= $ guardName . ": " . $ data ['guards ' ][$ guardName ]['name ' ] . ', ' ;
3741 }
@@ -47,6 +51,23 @@ public function collect()
4751
4852 return $ data ;
4953 }
54+
55+ private function resolveUser (Guard $ guard )
56+ {
57+ // if we're logging in using remember token
58+ // then we must resolve user „manually”
59+ // to prevent csrf token regeneration
60+
61+ $ usingSession = $ guard instanceof SessionGuard;
62+ $ recaller = $ usingSession ? $ guard ->getRequest ()->cookies ->get ($ guard ->getRecallerName ()) : null ;
63+
64+ if ($ usingSession && !is_null ($ recaller )) {
65+ list ($ id , $ token ) = explode ('| ' , $ recaller );
66+ return $ guard ->getProvider ()->retrieveByToken ($ id , $ token );
67+ } else {
68+ return $ guard ->user ();
69+ }
70+ }
5071
5172 /**
5273 * @{inheritDoc}
You can’t perform that action at this time.
0 commit comments