Skip to content
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

Make sure roles always use web guard name #690

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/Filament/Resources/RoleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Enums\RolePermissionPrefixes;
use App\Filament\Resources\RoleResource\Pages;
use App\Models\Role;
use Filament\Facades\Filament;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\Component;
Expand Down Expand Up @@ -71,7 +70,7 @@ public static function form(Form $form): Form
->disabled(fn (Get $get) => $get('name') === Role::ROOT_ADMIN),
TextInput::make('guard_name')
->label('Guard Name')
->default(Filament::getCurrentPanel()?->getAuthGuard() ?? '')
->default(Role::DEFAULT_GUARD_NAME)
->nullable()
->hidden(),
Fieldset::make('Permissions')
Expand Down
4 changes: 3 additions & 1 deletion app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Role extends BaseRole

public const ROOT_ADMIN = 'Root Admin';

public const DEFAULT_GUARD_NAME = 'web';

public const MODEL_SPECIFIC_PERMISSIONS = [
'egg' => [
'import',
Expand All @@ -41,7 +43,7 @@ public function isRootAdmin(): bool
public static function getRootAdmin(): self
{
/** @var self $role */
$role = self::findOrCreate(self::ROOT_ADMIN);
$role = self::findOrCreate(self::ROOT_ADMIN, self::DEFAULT_GUARD_NAME);

return $role;
}
Expand Down
Loading