Skip to content

Commit

Permalink
Make sure roles always use web guard name (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 authored Oct 29, 2024
1 parent 3f9c1db commit 7a447b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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

0 comments on commit 7a447b0

Please sign in to comment.