src/Subfission/Cas/Middleware/CASAuth.php
public function handle($request, Closure $next)
    {
        if( $this->cas->checkAuthentication() )
        {
            // Store the user credentials in a Laravel managed session
            session()->put('cas_user', $this->cas->user());
        } else {
            if ($request->ajax() || $request->wantsJson()) {
                return response('Unauthorized.', 401);
            }
            $this->cas->authenticate();
        }

        return $next($request);
    }
public function handle($request, Closure $next)
    {
        if( $this->cas->checkAuthentication() )
        {
            // Store the user credentials in a Laravel managed session
            session()->put('cas_user', $this->cas->user());
        } else {
            if ($request->ajax() || $request->wantsJson()) {
                return response('Unauthorized.', 401);
            }
            $this->cas->authenticate();
        }

        return $next($request);
    }
Handle an incoming request.

@param  \Illuminate\Http\Request $request
@param  \Closure $next
@return mixed