fix(admin): derive legacy datacenter location allowlist from DB, not client property
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>feat/portal-design
parent
3a794b05dd
commit
507ab485a0
|
|
@ -39,12 +39,15 @@ class EditDatacenter extends ModalComponent
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
$this->authorize('datacenters.manage');
|
$this->authorize('datacenters.manage');
|
||||||
|
|
||||||
// Accept the configured countries plus the record's own legacy value, so a
|
// Accept the configured countries plus the record's own legacy value, so a
|
||||||
// datacenter created before the curated list can still be edited (e.g. a
|
// datacenter created before the curated list can still be edited. The
|
||||||
// name-only change) without being forced to replace a free-form location.
|
// legacy value is read from the DB — never from the client-hydrated
|
||||||
|
// property, which could be forged to whitelist an arbitrary location.
|
||||||
|
$dc = Datacenter::query()->where('uuid', $this->uuid)->firstOrFail();
|
||||||
$allowed = array_keys((array) config('countries'));
|
$allowed = array_keys((array) config('countries'));
|
||||||
if ($this->originalLocation !== '') {
|
if ($dc->location) {
|
||||||
$allowed[] = $this->originalLocation;
|
$allowed[] = $dc->location;
|
||||||
}
|
}
|
||||||
$data = $this->validate([
|
$data = $this->validate([
|
||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue