Skip to content

Commit

Permalink
Pass whole Guard instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Propaganistas committed Aug 19, 2018
1 parent 69cdded commit 76da465
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Events/Attempting.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Attempting
/**
* The guard this attempt is made to.
*
* @var string
* @var \Illuminate\Contracts\Auth\StatefulGuard
*/
public $guard;

Expand All @@ -30,7 +30,7 @@ class Attempting
*
* @param array $credentials
* @param bool $remember
* @param string $guard
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
* @return void
*/
public function __construct($credentials, $remember, $guard)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Events/Authenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class Authenticated
/**
* The guard the user is authenticating to.
*
* @var string
* @var \Illuminate\Contracts\Auth\StatefulGuard
*/
public $guard;

/**
* Create a new event instance.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $guard
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
* @return void
*/
public function __construct($user, $guard)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Events/Failed.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Failed
/**
* The guard the user failed to authenticated to.
*
* @var string
* @var \Illuminate\Contracts\Auth\StatefulGuard
*/
public $guard;

Expand All @@ -30,7 +30,7 @@ class Failed
*
* @param \Illuminate\Contracts\Auth\Authenticatable|null $user
* @param array $credentials
* @param string $guard
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
* @return void
*/
public function __construct($user, $credentials, $guard)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Events/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Login
/**
* The guard the user authenticated to.
*
* @var string
* @var \Illuminate\Contracts\Auth\StatefulGuard
*/
public $guard;

Expand All @@ -34,7 +34,7 @@ class Login
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param bool $remember
* @param string $guard
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
* @return void
*/
public function __construct($user, $remember, $guard)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Events/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class Logout
/**
* The guard to which the user was authenticated.
*
* @var string
* @var \Illuminate\Contracts\Auth\StatefulGuard
*/
public $guard;

/**
* Create a new event instance.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $guard
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard
* @return void
*/
public function __construct($user, $guard)
Expand Down
24 changes: 17 additions & 7 deletions src/Illuminate/Auth/SessionGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public function logout()
}

if (isset($this->events)) {
$this->events->dispatch(new Events\Logout($user, $this->name));
$this->events->dispatch(new Events\Logout($user, $this));
}

// Once we have fired the logout event we will clear the users out of memory
Expand Down Expand Up @@ -576,7 +576,7 @@ protected function fireAttemptEvent(array $credentials, $remember = false)
{
if (isset($this->events)) {
$this->events->dispatch(new Events\Attempting(
$credentials, $remember, $this->name
$credentials, $remember, $this
));
}
}
Expand All @@ -592,7 +592,7 @@ protected function fireLoginEvent($user, $remember = false)
{
if (isset($this->events)) {
$this->events->dispatch(new Events\Login(
$user, $remember, $this->name
$user, $remember, $this
));
}
}
Expand All @@ -607,7 +607,7 @@ protected function fireAuthenticatedEvent($user)
{
if (isset($this->events)) {
$this->events->dispatch(new Events\Authenticated(
$user, $this->name
$user, $this
));
}
}
Expand All @@ -623,7 +623,7 @@ protected function fireFailedEvent($user, array $credentials)
{
if (isset($this->events)) {
$this->events->dispatch(new Events\Failed(
$user, $credentials, $this->name
$user, $credentials, $this
));
}
}
Expand All @@ -645,7 +645,7 @@ public function getLastAttempted()
*/
public function getName()
{
return 'login_'.$this->name.'_'.sha1(static::class);
return 'login_'.$this->getGuardName().'_'.sha1(static::class);
}

/**
Expand All @@ -655,7 +655,17 @@ public function getName()
*/
public function getRecallerName()
{
return 'remember_'.$this->name.'_'.sha1(static::class);
return 'remember_'.$this->getGuardName().'_'.sha1(static::class);
}

/**
* Get the name of the guard, corresponding to name in authentication configuration.
*
* @return string
*/
public function getGuardName()
{
return $this->name;
}

/**
Expand Down

0 comments on commit 76da465

Please sign in to comment.