From 877956958705f6e6013036ff9ee397389c55cd33 Mon Sep 17 00:00:00 2001 From: Debian Date: Mon, 5 Jan 2026 03:42:40 +0000 Subject: [PATCH] Fix Uptime Kuma login not prompting for TOTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- backend/services/kuma_client.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/backend/services/kuma_client.py b/backend/services/kuma_client.py index 813dbfa..704437f 100644 --- a/backend/services/kuma_client.py +++ b/backend/services/kuma_client.py @@ -128,15 +128,27 @@ class UptimeKumaClient: else: 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") - if token: - save_token(token) - self._token = token + if not token: + api.disconnect() + raise Exception("Login failed: No authentication token received") + + save_token(token) + self._token = token api.disconnect() return {"success": True, "message": "Login successful"} 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: """Check if we have valid authentication."""