Oct 11, 2022
0
Level 1
Laravel Auth::user with Bouncer for roles
I have an app where I am using "silber/bouncer": "^1.0" and Laravel Auth::user(). The problem I am observing is that after a few clicks around the application apparently the Auth::user() becomes null and then I get an error:
Silber\Bouncer\Bouncer::is(): Argument #1 ($authority) must be of type Illuminate\Database\Eloquent\Model, null given, called in /public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 338 {"exception":"[object] (TypeError(code: 0): Silber\Bouncer\Bouncer::is(): Argument #1 ($authority) must be of type Illuminate\Database\Eloquent\Model, null given, called in public_html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 338 at /home/837208.cloudwaysapps.com/xxejmecxby/public_html/vendor/silber/bouncer/src/Bouncer.php:187)
Or on my first log-in into the app I get a 419 Page expired with the same error as above and I have to log in a second time which always works. But then again after some time I just get the same error and I am redirected to my login page. This means that my authentication middleware is failing or I am missing something.
Please or to participate in this conversation.