-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Laravel pulse does not work with specific guard different than the default guard #311
Comments
Hey there, Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out. Thanks! |
@CostiNec, in the docs we reference the |
That also happens for me. I'll take some time to try to figure it out. |
<?php
namespace App\Services;
use Closure;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Http\Request;
class AuthorizePulse
{
public function handle(Request $request, Closure $next): mixed
{
// $this->gate->authorize('viewPulse');
abort_unless(auth('admin')->check(), 404, 'Access denied');
if ($this->gate->forUser(auth('admin')->user())->allows('viewPulse')) {
return $next($request);
}
abort(404, 'Access denied');
}
} Then in the 'middleware' => [
'web',
AuthorizePulse::class, // add this class
], |
Pulse Version
1.0@beta
Laravel Version
10.0
PHP Version
8.1.20
Livewire Version
3.0.2
Database Driver & Version
mysql Ver 8.0.36-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
Description
I have a different guard for my admins. My guard is not the default guard.
`'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
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
The text was updated successfully, but these errors were encountered: