Support the ongoing development of Laravel.io →
posted 9 years ago
Authentication

Hey,

i'm working on my first Laravel project but i don't get the authentication working! I just did

php artisan make:auth

The views and routes are working fine! I registered a user, checked the database and everything is set up.

I can login using the view../auth/login and get redirected. But then...

When i go to /auth/login again, i get redirected. So the login page sees me loged in i guess. But
var_dump(Auth::user());

is always NULL

I tried to set something like this in routes: Route::get('admin', [ 'middleware' => 'auth', 'uses' => 'AdminController@show' ]);

But when i go to ../admin it redirects me to /login instead of /auth/login

Last updated 3 years ago.
0

Since Laravel 5.2 all User aware routes must use 'web' middleware;

0

aleex, check "app/Http/Kernel.php" where middleware is defined.

There you can check middleware groups. You can see that in the web middleware group you have things for session and cookies (which is used for auth).

Also, theres information on it at https://laravel.com/docs/master/middleware and Laracasts.

Im guessing Rikcons answer is correct, however I just read the problem but did not spend time on it since no using the web middleware is a classic source of errors in laravel 5.2

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

aleex aleex Joined 1 Mar 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.