From 8774e850b6c51b354ca98ca4ccf6780d5fb5cefa Mon Sep 17 00:00:00 2001 From: Sejong Yoo Date: Sat, 24 Oct 2026 21:43:56 +0900 Subject: [PATCH] fix: treat a logged-out launcher (autologin off, token 0) as needing login Co-Authored-By: Claude Opus 5.5 --- py_modules/mudfish_decky/client.py | 3 ++- tests/test_client.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/py_modules/mudfish_decky/client.py b/py_modules/mudfish_decky/client.py index 88ffff6..4cde055 100644 --- a/py_modules/mudfish_decky/client.py +++ b/py_modules/mudfish_decky/client.py @@ -93,7 +93,8 @@ class MudfishClient: st = self.status() if st.get("isSignedIn") and not force: return st - if not st.get("token_v3") or not st.get("username"): + # A logged-out launcher reports autologin=False and token_v3="0". + if not st.get("autologin") or str(st.get("token_v3") or "0") == "0" or not st.get("username"): raise SigninError("no saved login") body, ctype = _multipart({ "autologin": "ON", "username": st["username"], "password": st["token_v3"], diff --git a/tests/test_client.py b/tests/test_client.py index 8590ce3..e5fbf2e 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -4,7 +4,7 @@ import unittest from mudfish_decky.client import AuthError, MudfishClient, MudfishError, SigninError BASE = "http://127.0.0.1:8282" -SIGNED_OUT = {"status": 200, "isSignedIn": False, "username": "u", "token_v3": "123", +SIGNED_OUT = {"status": 200, "isSignedIn": False, "autologin": True, "username": "u", "token_v3": "123", "item_conf_mode": "simple", "version": "6.6.0", "api_server": "api.mudfish.net", "jwt": ""} SIGNIN_OK = {"status": 200, "token_v3": "456", "jwt": "JWT", "expert_mode": 0, "lang": "ko_KR", "alias_enable": 0} @@ -100,6 +100,13 @@ class ClientTest(unittest.TestCase): with self.assertRaises(SigninError): MudfishClient(BASE, t).ensure_signed_in() + def test_logged_out_launcher_is_signin_error_without_calling_cloud(self): + # After /logout.html the launcher reports autologin=False and token_v3="0". + t = FakeTransport({("GET", BASE + "/do/mudrun/status"): [dict(SIGNED_OUT, autologin=False, token_v3="0")]}) + with self.assertRaises(SigninError): + MudfishClient(BASE, t).ensure_signed_in() + self.assertEqual(t.calls_to("POST", "https://api.mudfish.net/signin_ng_v3"), []) + def test_graphql_without_user_is_auth_error(self): t = FakeTransport({("POST", "https://api.mudfish.net/graphql"): [{"errors": ["unauthorized"]}]}) with self.assertRaises(AuthError):