mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 07:26:18 -05:00
Hotspot: address review comments.
* POST /api/hotspot/settings checks is_docker_mode() directly instead of string-matching the error message (still 500, matching the sibling hotspot/bluetooth/throttle endpoints). * Escape \ ; , " in the WiFi QR code per the WPA QR format. * Skip the controller.yaml write when a settings update changes nothing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
0d2c13e4e7
commit
2887309aae
4 changed files with 27 additions and 8 deletions
|
|
@ -83,11 +83,12 @@ async def hotspot_settings() -> HotspotSettingsResponse:
|
|||
@router.post("/api/hotspot/settings", response_model=HotspotSettingsResponse)
|
||||
async def hotspot_settings_update(request: HotspotSettingsRequest) -> HotspotSettingsResponse:
|
||||
"""Update WiFi hotspot settings; they are saved in controller.yaml."""
|
||||
# 500 matches the other subsystem endpoints (hotspot/bluetooth/throttle) in Docker mode.
|
||||
if is_docker_mode():
|
||||
raise HTTPException(status_code=500, detail="Not available in Docker mode")
|
||||
result = update_hotspot_settings(device=request.device, ssid=request.ssid, password=request.password)
|
||||
if not result.get("success"):
|
||||
error = result.get("error", "Failed")
|
||||
status_code = 500 if "Docker" in error else 400
|
||||
raise HTTPException(status_code=status_code, detail=error)
|
||||
raise HTTPException(status_code=400, detail=result.get("error", "Failed"))
|
||||
return HotspotSettingsResponse(device=result["device"], ssid=result["ssid"], password=result["password"])
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue