From 3a4308713d469ebba483a0ea390493c1184ea14f Mon Sep 17 00:00:00 2001 From: Joseph Silber Date: Sun, 19 Jun 2016 23:31:08 -0400 Subject: [PATCH] Remove the guard parameter from AuthenticationException (#14067) --- AuthenticationException.php | 25 +++---------------------- GuardHelpers.php | 2 +- Middleware/Authenticate.php | 6 ++---- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/AuthenticationException.php b/AuthenticationException.php index 142afd1c8..347cfe742 100644 --- a/AuthenticationException.php +++ b/AuthenticationException.php @@ -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); } } diff --git a/GuardHelpers.php b/GuardHelpers.php index 95fee3ae7..5a227964d 100644 --- a/GuardHelpers.php +++ b/GuardHelpers.php @@ -36,7 +36,7 @@ public function authenticate() return $user; } - throw new AuthenticationException($this); + throw new AuthenticationException; } /** diff --git a/Middleware/Authenticate.php b/Middleware/Authenticate.php index 7667a781d..6f52c1691 100644 --- a/Middleware/Authenticate.php +++ b/Middleware/Authenticate.php @@ -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) {