File tree Expand file tree Collapse file tree 2 files changed +31
-10
lines changed
Expand file tree Collapse file tree 2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,6 @@ public function user()
149149 // pull the user data on that cookie which serves as a remember cookie on
150150 // the application. Once we have a user we can return it to the caller.
151151 $ recaller = $ this ->getRecaller ();
152-
153152 if (is_null ($ user ) && ! is_null ($ recaller ))
154153 {
155154 $ user = $ this ->getUserByRecaller ($ recaller );
@@ -167,7 +166,7 @@ public function id()
167166 {
168167 if ($ this ->loggedOut ) return ;
169168
170- $ id = $ this ->session ->get ($ this ->getName (), $ this -> getRecallerId () );
169+ $ id = $ this ->session ->get ($ this ->getName ());
171170
172171 if (is_null ($ id ) && $ this ->user ())
173172 {
@@ -210,15 +209,14 @@ protected function getRecaller()
210209 /**
211210 * Get the user ID from the recaller cookie.
212211 *
213- * @return string
212+ * @return int
214213 */
215- protected function getRecallerId ()
216- {
217- if ($ this ->validRecaller ($ recaller = $ this ->getRecaller ()))
218- {
219- return head (explode ('| ' , $ recaller ));
220- }
221- }
214+ protected function getRecallerId ()
215+ {
216+ if ($ this ->validRecaller ($ recaller = $ this ->getRecaller ())) {
217+ return (int ) head (explode ('| ' , $ recaller ));
218+ }
219+ }
222220
223221 /**
224222 * Determine if the recaller cookie is in a valid format.
Original file line number Diff line number Diff line change @@ -374,4 +374,27 @@ public function testUserUsesRememberCookieIfItExists()
374374 $ this ->assertEquals ($ user ->reveal (), $ guard ->user ());
375375 $ this ->assertTrue ($ guard ->viaRemember ());
376376 }
377+
378+ public function testGetIdWhenRememberCookieExistsWillReturnIntegerIdFromCookieValue ()
379+ {
380+ $ request = Request::create ('/ ' , 'GET ' , [], [
381+ 'remember_82e5d2c56bdd0811318f0cf078b78bfc ' => '123|recaller '
382+ ]);
383+ $ user = $ this ->prophesize (UserInterface::class);
384+ $ user ->getAuthIdentifier ()->willReturn (123 );
385+
386+ $ this ->userProvider
387+ ->retrieveByToken (123 , 'recaller ' )
388+ ->willReturn ($ user ->reveal ());
389+
390+ $ guard = new Guard (
391+ $ this ->userProvider ->reveal (),
392+ $ this ->session ->reveal (),
393+ $ request
394+ );
395+
396+ $ this ->assertNotNull ($ guard ->id ());
397+ $ this ->assertIsInt ($ guard ->id ());
398+ $ this ->assertSame (123 , $ guard ->id ());
399+ }
377400}
You can’t perform that action at this time.
0 commit comments