0

I am using one laravel 5.7 authentication with custom check and session. I have 5 type of user types

Session::put('user_type', $user_type); Session::put('user_id', $user_id);

When I tried to check session data in constructor I am facing one issue,Please hele me to solve this,

ErrorException (E_NOTICE) Trying to get property 'headers' of non-object

 public function __construct()
    {              
        $this->middleware(function ($request, $next) {
        $utype=Session::get('user_type');
        if($utype != 'ProjectAdmin'){
            return redirect()->route('login');
        }else{
            $this->objShareContract = shareContract::getShareContract(TRUE);
        }
    });
    }

1 Answer 1

2

Middleware must return a Response. You are not returning a Response from this custom Closure based middleware. You have 2 logical paths and only one of them is returning a Response of some sort.

There are other middleware before this one that are expecting a Response to come back through the pipeline. That is what the return $next($request); is about.

Sign up to request clarification or add additional context in comments.

1 Comment

okay thanks.if($utype != 'ProjectAdmin'){ return redirect()->route('login'); } $this->objShareContract = shareContract::getShareContract(TRUE); return $next($request); I changed like these now working,Thanks..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.