Merge pull request #4904 from Te7a-Houdini/modify-redirect-if-auth-middleware-to-allow-multiple-guards

[5.8] Modify RedirectIfAuthenticated middleware to accept multiple guards
This commit is contained in:
Taylor Otwell 2019-01-16 09:06:56 -06:00 committed by GitHub
commit 2d2c089a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

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