Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CostiNec's avatar

Laravel pulse does not work with specific guard different than the default guard

I tried to report the issue on github, but my issue was closed in like 2 hours and the response was: Try another sites for answers. Did I do something wrong? Here is my problem:

I have a different guard for my admins. My guard is not the default guard.

`'defaults' => [ 'guard' => 'web', 'passwords' => 'users', ],

/* |--------------------------------------------------------------------------

Authentication Guards Next, you may define every authentication guard for your application. Of course, a great default configuration has been defined for you here which uses session storage and the Eloquent user provider. All authentication drivers have a user provider. This defines how the users are actually retrieved out of your database or other storage mechanisms used by this application to persist your user's data. Supported: "session" */

'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'admins' => [ 'driver' => 'session', 'provider' => 'admins', ], ],`

My guard is using a custom model named AdminUser instead of User. If I set up in AuthServiceProvider:

Gate::define('viewPulse', function () { return true; }); I receive 403 no matter what because I have a different guard for my admins and laravel pulse does not see that I'm logged in.

Also I use laravel nova for my admins.

I think the solution is to make the guard used for laravel pulse configurable in config/pulse.php

Steps To Reproduce Create a new guard: 'admins' => [ 'driver' => 'session', 'provider' => 'admins', ],

Create a new provider for your guard: 'admins' => [ 'driver' => 'eloquent', 'model' => App\Models\AdminUser::class, ],

Install laravel nova and change the default guard.

Log in into nova as admin

Add in AuthServiceProvider: Gate::define('viewPulse', function () { return true; });

Try to access laravel pulse. You will receive 403

0 likes
5 replies
krisi_gjika's avatar

so you want only nova admins to access the pulse route? given your viewPulse returns true can you access the pulse route via a non admin user?

CostiNec's avatar

@krisi_gjika No I cannot access the route even tough viewPulse returns true. I can access the route only if I don't add Gate::define('viewPulse', function () { return true; }); at all and in I have in .env APP_ENV=local.

2 likes
pelmered's avatar

@CostiNec I have the same problem with a custom admin guard. Did you find a solution?

pelmered's avatar

Ah, I solved it. The User paramter in the viewPulse Gate needs to be nullable and then I needed to get the user manually with Auth::guard($guard)->user(); and then perform my auth checks.

1 like

Please or to participate in this conversation.