Fix isolated user validation (#450)

This commit is contained in:
Saeed Vaziry 2025-01-29 20:17:47 +01:00 committed by GitHub
parent d702b95e0c
commit 1e4a944acb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 4 deletions

View File

@ -114,7 +114,7 @@ public static function rules(Server $server, array $input): array
'regex:/^[a-z_][a-z0-9_-]*[a-z0-9]$/',
'min:3',
'max:32',
'unique:sites,user',
Rule::unique('sites', 'user')->where('server_id', $server->id),
Rule::notIn($server->getSshUsers()),
],
];

View File

@ -52,6 +52,7 @@ public function index(Project $project, Server $server): ResourceCollection
#[BodyParam(name: 'branch', description: 'Branch, Required for Sites which support source control', example: 'main')]
#[BodyParam(name: 'composer', type: 'boolean', description: 'Run composer if site supports composer', example: true)]
#[BodyParam(name: 'version', description: 'Version, if the site type requires a version like PHPMyAdmin', example: '5.2.1')]
#[BodyParam(name: 'user', description: 'user, to isolate the website under a new user')]
#[ResponseFromApiResource(SiteResource::class, Site::class)]
public function create(Request $request, Project $project, Server $server): SiteResource
{

View File

@ -134,9 +134,9 @@ protected function getHeaderActions(): array
// WordPress
$this->wordpressFields(),
TextInput::make('user')
->label('Username')
->hintIcon('heroicon-o-information-circle')
->hintIconTooltip(
->label('User')
->placeholder('vito')
->helperText(
'Optional. If provided, a new user will be created and the site will be owned by this user.'
)
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['user']),