feat(frontend): always-visible gun bays, idle/plugged/charging lamp language, self-service password

- Control renders every gun declared in the chargers registry, even when
  the charger is offline or has not reported that connector yet (state
  shows Offline / No status yet in gray)
- owner-specified state language: gray = idle, pulsing blue = cable in
  the socket (Preparing), green = charging; suspended/finishing = steady
  blue; fault = red
- POST /api/me/password (requires current password) + /account page,
  username in the topbar links to it
- smoke test: 58 checks (password change round-trip incl. old-password
  invalidation)
This commit is contained in:
2026-07-12 08:37:20 +02:00
parent 75869364b0
commit 3387f8689e
11 changed files with 229 additions and 48 deletions
+21
View File
@@ -107,6 +107,27 @@ async def me(user: dict = Depends(current_user)):
return users.public_view(user["name"], user)
class PasswordBody(BaseModel):
current_password: str
new_password: str
@router.post("/me/password")
async def change_own_password(body: PasswordBody, user: dict = Depends(current_user)):
"""Self-service password change — requires the current password.
(Admins can still reset anyone's via PUT /api/users/<name>.)"""
entry = CONFIG["users"].get(user["name"])
if entry is None:
raise HTTPException(409, "no user account — the API is in open mode")
if not users.verify_password(body.current_password, entry.get("password", "")):
raise HTTPException(403, "current password is wrong")
if len(body.new_password) < 4:
raise HTTPException(400, "new password must be at least 4 characters")
users.set_user(user["name"], password=body.new_password)
log.info("password changed by %r", user["name"])
return {"changed": True}
# ---- status & journals ----
@router.get("/status")
async def api_status(user: dict = Depends(current_user)):