Closed CostiNec closed 7 months ago
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 ResolvesUsers
contract which you may implement if you have multiple guards or a more complex user configuration.
That also happens for me.
I'll take some time to try to figure it out.
@gcjbr @CostiNec
<?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 config/pulse.php
'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