Tuesday, March 21, 2017

Laravel 5, why is a redirect to named route in middleware causing "localhost redirected you too many times"

I have a pretty straight forward middleware:

protected $auth;

public function __construct(Guard $auth)
{
    $this->auth = $auth;
}

/**
 * Handle an incoming request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
 */
public function handle($request, Closure $next)
{

    //dd($this->auth->user());
    if($this->auth->user()->id  && $this->auth->user()->pastDueFees()){
        \Session::flash('message','You must pay past due deal fees before using the rest of the website');
        return redirect()->route('profile.investment-fees');
    } 

    return $next($request);
}

This causes the redirect loop. I am only calling the middleware via Kernal.php.

thanks in advance.



via TJ Sherrill

Advertisement