Permalink
Browse files

Added new 'Auth::viaRemember method to determine if user was authed v…

…ia 'remember me' cookie.
  • Loading branch information...
taylorotwell committed Oct 28, 2013
1 parent 5483042 commit 2184ad4c8fe5f05b89ae1d5c6f87012cca150101
Showing with 22 additions and 1 deletion.
  1. +19 −0 src/Illuminate/Auth/Guard.php
  2. +2 −1 src/Illuminate/Foundation/changes.json
  3. +1 −0 tests/Auth/AuthGuardTest.php
@@ -16,6 +16,13 @@ class Guard {
*/
protected $user;
/**
* Indicates if the user was authenticated via a recaller cookie.
*
* @var bool
*/
protected $viaRemember = false;
/**
* The user provider implementation.
*
@@ -131,6 +138,8 @@ public function user()
if (is_null($user) and ! is_null($recaller))
{
$user = $this->provider->retrieveByID($recaller);
$this->viaRemember = ! is_null($user);
}
return $this->user = $user;
@@ -578,4 +587,14 @@ public function getRecallerName()
return 'remember_'.md5(get_class($this));
}
/**
* Determine if the user was authenticated via "remember me" cookie.
*
* @return bool
*/
public function viaRemember()
{
return $this->viaRemember;
}
}
@@ -30,7 +30,8 @@
{"message": "Added 'whereNotBetween' support to the query builder.", "backport": null},
{"message": "Added App::middleware method to inject middlewares onto Stack.", "backport": null},
{"message": "Deprecate 'close' application hooks, Stack middlewares should be used instead.", "backport": null},
{"message": "A new packages directory within `lang` can now override package language files.", "backport": null}
{"message": "A new packages directory within `lang` can now override package language files.", "backport": null},
{"message": "Added new 'Auth::viaRemember method to determine if user was authed via 'remember me' cookie.", "backport": null}
],
"4.0.x": [
{"message": "Added implode method to query builder and Collection class.", "backport": null},
@@ -226,6 +226,7 @@ public function testUserUsesRememberCookieIfItExists()
$user = m::mock('Illuminate\Auth\UserInterface');
$guard->getProvider()->shouldReceive('retrieveById')->once()->with('recaller')->andReturn($user);
$this->assertEquals($user, $guard->user());
$this->assertTrue($guard->viaRemember());
}

0 comments on commit 2184ad4

Please sign in to comment.