From 00acbf89c1cab247db6fe531e8128f12f39e343d Mon Sep 17 00:00:00 2001 From: Roger Joys Date: Mon, 16 Mar 2026 05:48:52 -0700 Subject: [PATCH] Changed Success UX --- app/main.py | 2 ++ app/templates/success.html | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 3276c2d..9bcecc5 100644 --- a/app/main.py +++ b/app/main.py @@ -96,6 +96,7 @@ async def callback(request: Request, code: str, state: str): duration = get_guest_duration(userinfo, site.default_duration_minutes) success = authorize_guest(site, mac, duration) + user_agent = request.headers.get("user-agent", "").lower() if not success: return templates.TemplateResponse("error.html", { @@ -109,4 +110,5 @@ async def callback(request: Request, code: str, state: str): "userinfo": userinfo, "duration_hours": duration // 60, "original_url": original_url, + "user_agent": user_agent, }) \ No newline at end of file diff --git a/app/templates/success.html b/app/templates/success.html index 64b26ce..b914f9a 100644 --- a/app/templates/success.html +++ b/app/templates/success.html @@ -12,7 +12,16 @@ el.textContent = seconds; if (seconds <= 0) { clearInterval(timer); - window.location.href = "{{ original_url }}"; + const ua = "{{ user_agent }}"; + if (ua.includes("iphone") || ua.includes("ipad") || ua.includes("mac")) { + window.location.href = "http://captive.apple.com/hotspot-detect.html"; + } else if (ua.includes("android")) { + window.location.href = "http://connectivitycheck.gstatic.com/generate_204"; + } else if (ua.includes("windows")) { + window.location.href = "http://www.msftconnecttest.com/connecttest.txt"; + } else { + window.location.href = "{{ original_url }}"; + } } }, 1000);