Mehdi
Allow only users with specific roles to access the login.
Try this:
namespace App\Models;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use BezhanSalleh\FilamentShield\Support\Utils;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements FilamentUser
{
//..
public function canAccessPanel(Panel $panel): bool { if($panel->getId() === 'admin') { return $this->hasRole(Utils::getSuperAdminName()); } elseif($panel->getId() === 'app') { return $this->hasRole(Utils::getSuperAdminName()) || $this->hasRole(config('filament-shield.user.name', 'user')); } return false; } }
public function canAccessPanel(Panel $panel): bool { if($panel->getId() === 'admin') { return $this->hasRole(Utils::getSuperAdminName()); } elseif($panel->getId() === 'app') { return $this->hasRole(Utils::getSuperAdminName()) || $this->hasRole(config('filament-shield.user.name', 'user')); } return false; } }
5 replies