Skip to content

Commit

Permalink
Use contracts for the RequirePassword middleware (#30215)
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Coder264 authored and taylorotwell committed Oct 9, 2019
1 parent 6e845d7 commit 53b6471
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/Illuminate/Auth/Middleware/RequirePassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,36 @@
namespace Illuminate\Auth\Middleware;

use Closure;
use Illuminate\Routing\Redirector;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Contracts\Routing\UrlGenerator;

class RequirePassword
{
/**
* The Redirector instance.
* The response factory instance.
*
* @var \Illuminate\Routing\Redirector
* @var \Illuminate\Contracts\Routing\ResponseFactory
*/
protected $redirector;
protected $responseFactory;

/**
* The URL generator instance.
*
* @var \Illuminate\Contracts\Routing\UrlGenerator
*/
protected $urlGenerator;

/**
* Create a new middleware instance.
*
* @param \Illuminate\Routing\Redirector $redirector
* @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory
* @param \Illuminate\Contracts\Routing\UrlGenerator $urlGenerator
* @return void
*/
public function __construct(Redirector $redirector)
public function __construct(ResponseFactory $responseFactory, UrlGenerator $urlGenerator)
{
$this->redirector = $redirector;
$this->responseFactory = $responseFactory;
$this->urlGenerator = $urlGenerator;
}

/**
Expand All @@ -36,8 +46,8 @@ public function __construct(Redirector $redirector)
public function handle($request, Closure $next, $redirectToRoute = null)
{
if ($this->shouldConfirmPassword($request)) {
return $this->redirector->guest(
$this->redirector->getUrlGenerator()->route($redirectToRoute ?? 'password.confirm')
return $this->responseFactory->redirectGuest(
$this->urlGenerator->route($redirectToRoute ?? 'password.confirm')
);
}

Expand Down

0 comments on commit 53b6471

Please sign in to comment.