@@ -50,21 +50,27 @@ public function setShowName($showName)
50
50
*/
51
51
public function collect ()
52
52
{
53
- $ data = [];
53
+ $ data = [
54
+ 'guards ' => [],
55
+ ];
54
56
$ names = '' ;
55
57
56
58
foreach ($ this ->guards as $ guardName => $ config ) {
57
59
try {
58
- $ user = $ this ->resolveUser ($ this ->auth ->guard ($ guardName ), $ config );
60
+ $ guard = $ this ->auth ->guard ($ guardName );
61
+ if ($ this ->hasUser ($ guard )) {
62
+ $ user = $ guard ->user ();
63
+
64
+ if (!is_null ($ user )) {
65
+ $ data ['guards ' ][$ guardName ] = $ this ->getUserInformation ($ user );
66
+ $ names .= $ guardName . ": " . $ data ['guards ' ][$ guardName ]['name ' ] . ', ' ;
67
+ }
68
+ } else {
69
+ $ data ['guards ' ][$ guardName ] = null ;
70
+ }
59
71
} catch (\Exception $ e ) {
60
72
continue ;
61
73
}
62
-
63
- $ data ['guards ' ][$ guardName ] = $ this ->getUserInformation ($ user );
64
-
65
- if (!is_null ($ user )) {
66
- $ names .= $ guardName . ": " . $ data ['guards ' ][$ guardName ]['name ' ] . ', ' ;
67
- }
68
74
}
69
75
70
76
foreach ($ data ['guards ' ] as $ key => $ var ) {
@@ -78,23 +84,18 @@ public function collect()
78
84
return $ data ;
79
85
}
80
86
81
- private function resolveUser (Guard $ guard, array $ config )
87
+ private function hasUser (Guard $ guard )
82
88
{
83
- // if we're logging in using remember token
84
- // then we must resolve user „manually”
85
- // to prevent csrf token regeneration
86
- if ($ guard instanceof SessionGuard) {
87
-
88
- $ recaller = new Recaller ($ guard ->getRequest ()->cookies ->get ($ guard ->getRecallerName ()));
89
- $ provider = $ this ->auth ->createUserProvider ($ config ['provider ' ]);
89
+ if (method_exists ($ guard , 'hasUser ' )) {
90
+ return $ guard ->hasUser ();
91
+ }
90
92
91
- $ user = $ provider ->retrieveByToken ($ recaller ->id (), $ recaller ->token ());
92
- if ($ user ) {
93
- return $ user ;
94
- }
93
+ // For Laravel 5.5
94
+ if (method_exists ($ guard , 'alreadyAuthenticated ' )) {
95
+ return $ guard ->alreadyAuthenticated ();
95
96
}
96
97
97
- return $ guard -> user () ;
98
+ return false ;
98
99
}
99
100
100
101
/**
0 commit comments