Auth is not returning user information in my package

Published 1 week ago by nageshbadgujar

I am creating a package in laravel, but inside the controller, when I print Auth::user(), it does not prints user information.

I have created Auth using "php artisan make:auth" command, also use namespace for Auth. It does not show user login also.

Snapey
Snapey
1 week ago (647,375 XP)

well, of course you have to be able to login first!

nageshbadgujar

Yes, I have logged in.

Snapey
Snapey
1 week ago (647,375 XP)

and is your controller executed in response to a http request?

nageshbadgujar

Yes Snapey, By the way I missed the "web" middleware in my routes. It solved my problem.

Thanks for the help.

Snapey
Snapey
1 week ago (647,375 XP)

You should not need it, it is included by default unless a) you are using the api routes or b) you are using a version prior to 5.1

... I suppose if you have private routes for your package, and not in web.php then I could see you would need to specify middleware

nageshbadgujar

No, I am using 5.5. But I think we have to add "web" middleware in route group for custom packages.

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