Skip to content

Commit

Permalink
Remove the guard parameter from AuthenticationException (#14067)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephSilber authored and taylorotwell committed Jun 20, 2016
1 parent 34f8f28 commit 3a43087
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
25 changes: 3 additions & 22 deletions AuthenticationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,13 @@

class AuthenticationException extends Exception
{
/**
* The guard instance.
*
* @var \Illuminate\Contracts\Auth\Guard
*/
protected $guard;

/**
* Create a new authentication exception.
*
* @param \Illuminate\Contracts\Auth\Guard|null $guard
*/
public function __construct($guard = null)
{
$this->guard = $guard;

parent::__construct('Unauthenticated.');
}

/**
* Get the guard instance.
*
* @return \Illuminate\Contracts\Auth\Guard|null
* @param string $message
*/
public function guard()
public function __construct($message = 'Unauthenticated.')
{
return $this->guard;
parent::__construct($message);
}
}
2 changes: 1 addition & 1 deletion GuardHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function authenticate()
return $user;
}

throw new AuthenticationException($this);
throw new AuthenticationException;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ public function handle($request, Closure $next, ...$guards)
*/
protected function authenticate(array $guards)
{
if (count($guards) <= 1) {
$this->auth->guard($guard = array_first($guards))->authenticate();

return $this->auth->shouldUse($guard);
if (! $guards) {
return $this->auth->authenticate();
}

foreach ($guards as $guard) {
Expand Down

0 comments on commit 3a43087

Please sign in to comment.