allow guard to be specified on middleaware

This commit is contained in:
Taylor Otwell 2015-12-05 21:56:17 -06:00
parent c2c8ab6f5f
commit 2ea2ae0f3f
2 changed files with 6 additions and 4 deletions

View File

@ -12,11 +12,12 @@ class Authenticate
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next)
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guest()) {
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {

View File

@ -12,11 +12,12 @@ class RedirectIfAuthenticated
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next)
public function handle($request, Closure $next, $guard = null)
{
if (Auth::check()) {
if (Auth::guard($guard)->check()) {
return redirect('/');
}