Bound session_minutes to its column so an oversized value 422s (#5)
`unifi_vlan_mappings.session_minutes` is `unsignedInteger` (ceiling 4294967295) but the mapping validator only said `integer|min:1`. Anything larger reached the INSERT and raised SQLSTATE 22003, so the request died as an unhandled 500 where a validation error belongs — the same shape just fixed in central-oncall#7. Adds `max:525600` (a year of minutes) to both storeMapping and updateMapping. Found while fixing #5, which reported a *silent* rejection rather than a crash. The VLAN ID validation the issue was actually about was already correct on the server (`min:1|max:4094` on all three forms); what was missing was any way to see it, and that half of the fix is in the shell's Unifi/Portal.vue. Sibling numeric fields were checked at the same time: `vlan_id` (unsignedSmallInteger, bounded 1–4094) and `max_devices` (unsignedTinyInteger, bounded 1–50) were already safe against their columns; `session_minutes` was the only one that could overflow. Version 1.13.3 -> 1.13.4. Test: dashboard-shell tests/Feature/Unifi/VlanGroupValidationTest.php Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dashboard/unifi",
|
||||
"description": "UniFi network management, WiFi stats, and captive portal authentication for the Dashboard platform",
|
||||
"version": "1.13.3",
|
||||
"version": "1.13.4",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
|
||||
@@ -36,7 +36,11 @@ class PortalController extends Controller
|
||||
'match_value' => 'required|string|max:255',
|
||||
'vlan_id' => 'required|integer|min:1|max:4094',
|
||||
'max_devices' => 'required|integer|min:1|max:50',
|
||||
'session_minutes' => 'required|integer|min:1',
|
||||
// Bounded by the column that stores it: unifi_vlan_mappings.session_minutes
|
||||
// is unsignedInteger, so an unbounded value reached the INSERT and raised
|
||||
// SQLSTATE 22003 — a 500 where a validation error belongs (central-unifi#5).
|
||||
// 525600 minutes is a year, far more session than anyone will ever grant.
|
||||
'session_minutes' => 'required|integer|min:1|max:525600',
|
||||
]);
|
||||
$data['sort_order'] = VlanMapping::max('sort_order') + 1;
|
||||
VlanMapping::create($data);
|
||||
@@ -51,7 +55,11 @@ class PortalController extends Controller
|
||||
'match_value' => 'required|string|max:255',
|
||||
'vlan_id' => 'required|integer|min:1|max:4094',
|
||||
'max_devices' => 'required|integer|min:1|max:50',
|
||||
'session_minutes' => 'required|integer|min:1',
|
||||
// Bounded by the column that stores it: unifi_vlan_mappings.session_minutes
|
||||
// is unsignedInteger, so an unbounded value reached the INSERT and raised
|
||||
// SQLSTATE 22003 — a 500 where a validation error belongs (central-unifi#5).
|
||||
// 525600 minutes is a year, far more session than anyone will ever grant.
|
||||
'session_minutes' => 'required|integer|min:1|max:525600',
|
||||
]);
|
||||
$mapping->update($data);
|
||||
return back()->with('success', 'Mapping updated.');
|
||||
|
||||
Reference in New Issue
Block a user