Here is my understanding... I could be wrong.. Im fairly new to laravel.
Auth::check only works...
You have to do Auth::attempt() AND redirect to a route. (this is where the session is set on redirect)
Once you do that your Auth::check() will work.
The problem was that I was wrongly overwriting the getAuthIdentifier()-method in my User class
public function getAuthIdentifier()
{
return $this->email; //should be changed to
return $this->id;
}
removing all overwritten methods also solves the problem
In my case, this command made Auth::check() work.
php artisan cache:clear
But a few days later, it doesn't work anymore. I tried to protect some URLs, so that I used auth middleware for a group of URLs. For some hours, everything's fine. But Auth::check() returns false again, though I did nothing.
Is that a bug of Laravel 5?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community