Show orange upload button when Strava/Garmin auth fails

GET /api/me/sync-status reads _strava_sync_status.json and
_garmin_sync_status.json for the logged-in user. On page load the nav
script checks this endpoint and, if either service has status=auth_error,
turns the upload arrow orange with a tooltip naming the disconnected
service(s).
This commit is contained in:
Davide Scaini
2026-05-16 20:27:43 +02:00
parent 0eb25620ef
commit 2c69e75842
2 changed files with 42 additions and 0 deletions
+23
View File
@@ -317,3 +317,26 @@ async def me_change_password(
raise HTTPException(400, "New password must be at least 8 characters")
_change_password(deps._get_db(), user.handle, new_pw)
return JSONResponse({"ok": True})
@router.get("/api/me/sync-status")
async def get_sync_status(
bincio_session: str | None = Cookie(default=None),
) -> JSONResponse:
"""Return the last sync status for Strava and Garmin for the logged-in user."""
user = deps._require_user(bincio_session)
user_dir = deps._get_data_dir() / user.handle
def _read_status(filename: str) -> dict | None:
p = user_dir / filename
try:
return json.loads(p.read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError):
return None
strava = _read_status("_strava_sync_status.json")
garmin = _read_status("_garmin_sync_status.json")
return JSONResponse({
"strava": strava,
"garmin": garmin,
})