Fix Uptime Kuma login not prompting for TOTP
All checks were successful
Build and Push Container / build (push) Successful in 30s

The login method was returning success even when no token was received,
which happens when 2FA is required. Now properly detects tokenRequired
response and validates token before claiming success.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-01-05 03:42:40 +00:00
parent 64a8462784
commit 8779569587

View File

@@ -128,15 +128,27 @@ class UptimeKumaClient:
else: else:
result = api.login(username, password) result = api.login(username, password)
# Check if 2FA is required
if result.get("tokenRequired"):
api.disconnect()
raise Exception("2FA token required. Please enter your TOTP code.")
token = result.get("token") token = result.get("token")
if token: if not token:
api.disconnect()
raise Exception("Login failed: No authentication token received")
save_token(token) save_token(token)
self._token = token self._token = token
api.disconnect() api.disconnect()
return {"success": True, "message": "Login successful"} return {"success": True, "message": "Login successful"}
except Exception as e: except Exception as e:
raise Exception(f"Login failed: {str(e)}") error_msg = str(e)
# Re-raise with clear message for 2FA requirement
if "tokenRequired" in error_msg or "2fa" in error_msg.lower():
raise Exception("2FA token required. Please enter your TOTP code.")
raise Exception(f"Login failed: {error_msg}")
def is_authenticated(self) -> bool: def is_authenticated(self) -> bool:
"""Check if we have valid authentication.""" """Check if we have valid authentication."""