Peter Peter - 1 year ago 74
PHP Question

Package development - auth check doesn't work

I have made a simple fresh Laravel 5.3 app for the purpose of developing a package. I have followed instructions from here and some modifications made in comments by user named Janis. Everything works perfectly.

Then I decided to upgrade the published view with

ID: {{Auth::id()}}.
not logged in

The current state of the app is uploaded to Github here.


The view the check doesn't work. I always have the
not logged in
How to make the
In another tab of my browser I am logged correclty.

A hint

I am not sure how to follow this hint

To do

Please instruct me how to make the
work in the view.

Answer Source

Since Laravel 5, any route in routes.php automatically uses the web middleware, but this does not happend with your packages routes.

To use Laravel's authentication into your package controllers and views you need to enforce the web middleware usage in to your package route.php using something like:

Route::group(['middleware' => 'web'], function () {
  // your package routes here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download