diff --git a/app/Enums/UserRole.php b/app/Enums/UserRole.php index e8770e5..c8f7166 100644 --- a/app/Enums/UserRole.php +++ b/app/Enums/UserRole.php @@ -21,16 +21,16 @@ enum UserRole: string implements HasLabel { case Administrator = 'administrator'; case Agency = 'agency'; - case DomainManager = 'domain-manager'; - case GroupManager = 'group-manager'; + case DomainAdmin = 'domain-admin'; + case GroupAdmin = 'group-admin'; public function getLabel(): string { return match ($this) { self::Administrator => __('Administrator'), self::Agency => __('Agency'), - self::DomainManager => __('Domain Manager'), - self::GroupManager => __('Group Manager'), + self::DomainAdmin => __('Domain Admin'), + self::GroupAdmin => __('Group Admin'), }; } } diff --git a/app/Filament/Pages/ManageZimbraSettings.php b/app/Filament/Pages/ManageZimbraSettings.php index 7ff9f56..27828a1 100644 --- a/app/Filament/Pages/ManageZimbraSettings.php +++ b/app/Filament/Pages/ManageZimbraSettings.php @@ -49,6 +49,8 @@ class ManageZimbraSettings extends SettingsPage ->required()->label(__('Admin User')), TextInput::make('adminPassword') ->password()->required()->label(__('Admin Password')), + TextInput::make('defaultDomain') + ->required()->label(__('Default Domain')), ]); } diff --git a/app/Filament/Resources/UserResource/Pages/CreateUser.php b/app/Filament/Resources/UserResource/Pages/CreateUser.php index 9e068cd..3378ee3 100644 --- a/app/Filament/Resources/UserResource/Pages/CreateUser.php +++ b/app/Filament/Resources/UserResource/Pages/CreateUser.php @@ -10,7 +10,7 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Enums\UserRole; use App\Filament\Resources\UserResource; -use App\Models\Domain; +use App\Settings\ZimbraSettings; use Filament\Forms\Form; use Filament\Forms\Components\{ Select, @@ -39,7 +39,7 @@ class CreateUser extends CreateRecord TextInput::make('name')->required()->label(__('Name')), TextInput::make('email')->email()->required()->unique() ->endsWith( - Domain::all()->pluck('name', 'name') + app(ZimbraSettings::class)->defaultDomain )->validationMessages([ 'unique' => __('The email address has already been taken.'), 'ends_with' => __('The email address does not belong to any domains.'), diff --git a/app/Settings/ZimbraSettings.php b/app/Settings/ZimbraSettings.php index 668429a..2367130 100644 --- a/app/Settings/ZimbraSettings.php +++ b/app/Settings/ZimbraSettings.php @@ -25,6 +25,8 @@ class ZimbraSettings extends Settings public string $adminPassword; + public string $defaultDomain; + public static function group(): string { return 'zimbra'; diff --git a/database/settings/2024_04_16_025540_create_zimbra_settings.php b/database/settings/2024_04_16_025540_create_zimbra_settings.php index 1e06338..583c8f8 100644 --- a/database/settings/2024_04_16_025540_create_zimbra_settings.php +++ b/database/settings/2024_04_16_025540_create_zimbra_settings.php @@ -9,5 +9,6 @@ return new class extends SettingsMigration $this->migrator->add('zimbra.serviceUrl', ''); $this->migrator->add('zimbra.adminUser', ''); $this->migrator->addEncrypted('zimbra.adminPassword', ''); + $this->migrator->add('zimbra.defaultDomain', ''); } };