iambaz
265
3
Laravel

How to use Auth middleware in my own package

Posted 2 years ago by iambaz

I have created a new package with some custom routes. Within these routes I need to access the Auth::id(). I have wrapped the routes with the usual auth middleware like so:

Route::group(['middleware' => 'auth'], function(){

    Route::get('/importer', '\Vendor\Package\Controllers\[email protected]');
    Route::post('/importer/import', '\Vendor\Package\Controllers\[email protected]');

});

When I navigate to any of my routes, I am redirected to /home even whilst logged in.

Do I need to register something in my package to set up the authentication environment?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.