vendredi 12 juillet 2019

Laravel combine / interlace two Middlewares

In my Laravel project there are two types of custom middlewares:

  1. Those who check if a specific user type (tutor or student) is logged in
  2. Those who check the permissions of the current user

Now I need to combine these two middlewares to check for example if a tutor is logged in and also to check if the tutor has permission to enter a class.

My routes/web.php looks like this:

// check tutor authentication 
Route::group('middleware' => ['auth:tutor']], function(){

    // Display routes that are enabled for all tutors like /profile

    // check if tutor has permission to enter class
    Route::group(['middleware' => 'class.permission'], function(){

       // Display class routes

    });

});

Unfortunately I get the following error: Trying to get property 'headers' of non-object Path: Project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php

I would be grateful for some help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire