berkayk
622
10
Laravel

Auth::user() returns unexpected user

Posted 3 years ago by berkayk

Hi,

I have a Laravel 5 app where users write some questions etc. Sometimes, Auth::user() returns another user's data and I am not able to find what causes this.

For instance, I have only one user in the database with status field is set to 1, where all others are defaulted to **0**. But sometimes, I see some users' questsions posted as admin. The method (in User model) I am using is pretty simple like

public function isAdmin(){
        return $this->status == 1;
    }

What could be causing this problem? From the logs I have written, Auth::user() returns an unexpected user, not this simple function is failing.

Thanks in advance.

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