From a8920ff23d540f00745dd1d7751d7442d5ce439a Mon Sep 17 00:00:00 2001 From: Khoa Vo Date: Thu, 1 Jan 2026 21:47:56 +0700 Subject: [PATCH] fix: auth status now handles list-format cookies from Cookie-Editor export --- backend/api/routes/auth.py | 13 +- cookies.json | 312 +++++++++++++++++++++++++++++++++++++ 2 files changed, 323 insertions(+), 2 deletions(-) create mode 100644 cookies.json diff --git a/backend/api/routes/auth.py b/backend/api/routes/auth.py index 0de4af2..0624034 100644 --- a/backend/api/routes/auth.py +++ b/backend/api/routes/auth.py @@ -100,10 +100,19 @@ async def auth_status(): try: with open(COOKIES_FILE, "r") as f: cookies = json.load(f) - has_session = "sessionid" in cookies + # Handle both dict and list formats + if isinstance(cookies, dict): + has_session = "sessionid" in cookies + cookie_count = len(cookies) + elif isinstance(cookies, list): + has_session = any(c.get("name") == "sessionid" for c in cookies if isinstance(c, dict)) + cookie_count = len(cookies) + else: + has_session = False + cookie_count = 0 return { "authenticated": has_session, - "cookie_count": len(cookies) + "cookie_count": cookie_count } except: pass diff --git a/cookies.json b/cookies.json new file mode 100644 index 0000000..d4f72b9 --- /dev/null +++ b/cookies.json @@ -0,0 +1,312 @@ +[ + { + "domain": ".www.tiktok.com", + "expirationDate": 1784039026, + "hostOnly": false, + "httpOnly": false, + "name": "delay_guest_mode_vid", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "8" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1768142590.076948, + "hostOnly": false, + "httpOnly": false, + "name": "msToken", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "qKUFutg-Q184Mo5kpuAm4XvPCCucGe3O2KXf5G9pHV61Hb9puK-ZVQ7XzexuVGLLzwmFZ1mVYOgR3QbKBXk58AX9UgPPPkWk_koDZF3e-gqQGg_9GGjcdIOxGN-JTL_g0FM4qN8NKV84LdU=" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.646103, + "hostOnly": false, + "httpOnly": true, + "name": "tt_session_tlb_tag", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "sttt%7C1%7C6M35zM57kkqAGSs_LSUdRP_________zyplxYaEARSr2PNU_6cKcB0lq4WRz1GKKY43u399i5hs%3D" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1798369620.645922, + "hostOnly": false, + "httpOnly": true, + "name": "sid_guard", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "e8cdf9ccce7b924a80192b3f2d251d44%7C1767265616%7C15552000%7CTue%2C+30-Jun-2026+11%3A06%3A56+GMT" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1798814589.722864, + "hostOnly": false, + "httpOnly": true, + "name": "ttwid", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "1%7CAYDsetgnxt5vzYX8hD6Wq2DQ4FXiL_pqcdLwHWwz6B8%7C1767278585%7C46a4b0b8d2fc0ee903d0e781593a0d2d7b491a49752c86f034adf69319d371a0" + }, + { + "domain": ".www.tiktok.com", + "expirationDate": 1767883392, + "hostOnly": false, + "httpOnly": false, + "name": "perf_feed_cache", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "{%22expireTimestamp%22:0%2C%22itemIds%22:[%22%22%2C%227584357225863335188%22%2C%227580369401002659079%22]}" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.645952, + "hostOnly": false, + "httpOnly": true, + "name": "uid_tt", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "44deb1e89d254f610eefd18c39ec97fa708e9c0f22c0207f7140c6ffd6c81b2c" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1772449601.742227, + "hostOnly": false, + "httpOnly": false, + "name": "passport_csrf_token_default", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "9c66ab10306611c75fa19c87e54fd31b" + }, + { + "domain": ".tiktok.com", + "hostOnly": false, + "httpOnly": false, + "name": "s_v_web_id", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": true, + "storeId": null, + "value": "verify_mjvcbi31_l3mxUEeU_ykis_4x6z_859S_8zEFmNseEnJU" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.64617, + "hostOnly": false, + "httpOnly": true, + "name": "ssid_ucp_v1", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "1.0.1-KDlhMTg2NTQ1MmJiZmNlZjgzYzNiZGU4ZjAyNzk1NWRkNTlkOTYxNjIKIQiBiIHG4PKvxV8Q0KrZygYYswsgDDC50ZfDBjgIQBJIBBADGgJteSIgZThjZGY5Y2NjZTdiOTI0YTgwMTkyYjNmMmQyNTFkNDQyTgog40q2JTBb3lGgiNKowpX3zbxplmW4zO3AUFhAo6LMB-wSIDpAp_OQ2Q5qEBZvL59v7fgLmw27UIxLQHoimzDg3U5BGAIiBnRpa3Rvaw" + }, + { + "domain": ".www.tiktok.com", + "expirationDate": 1793198587, + "hostOnly": false, + "httpOnly": false, + "name": "tiktok_webapp_theme", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "dark" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1799409936.219767, + "hostOnly": false, + "httpOnly": false, + "name": "_ttp", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "32XOXKxwj8YLtBQf0OBn4TvlkPN" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1772449620.645821, + "hostOnly": false, + "httpOnly": true, + "name": "cmpl_token", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "AgQYAPOF_hfkTtKPtFExgPKdOPKrXVkNUj-FDmCi6K4" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1772449620.645628, + "hostOnly": false, + "httpOnly": true, + "name": "multi_sids", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "6884525631502042113%3Ae8cdf9ccce7b924a80192b3f2d251d44" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1769857620.645892, + "hostOnly": false, + "httpOnly": true, + "name": "passport_auth_status_ss", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "966972581a398dbb9ead189c044cf98c%2C" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1772449601.742082, + "hostOnly": false, + "httpOnly": false, + "name": "passport_csrf_token", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "9c66ab10306611c75fa19c87e54fd31b" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.646041, + "hostOnly": false, + "httpOnly": true, + "name": "sessionid", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "e8cdf9ccce7b924a80192b3f2d251d44" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.646073, + "hostOnly": false, + "httpOnly": true, + "name": "sessionid_ss", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "e8cdf9ccce7b924a80192b3f2d251d44" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.646008, + "hostOnly": false, + "httpOnly": true, + "name": "sid_tt", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "e8cdf9ccce7b924a80192b3f2d251d44" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.646132, + "hostOnly": false, + "httpOnly": true, + "name": "sid_ucp_v1", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "1.0.1-KDlhMTg2NTQ1MmJiZmNlZjgzYzNiZGU4ZjAyNzk1NWRkNTlkOTYxNjIKIQiBiIHG4PKvxV8Q0KrZygYYswsgDDC50ZfDBjgIQBJIBBADGgJteSIgZThjZGY5Y2NjZTdiOTI0YTgwMTkyYjNmMmQyNTFkNDQyTgog40q2JTBb3lGgiNKowpX3zbxplmW4zO3AUFhAo6LMB-wSIDpAp_OQ2Q5qEBZvL59v7fgLmw27UIxLQHoimzDg3U5BGAIiBnRpa3Rvaw" + }, + { + "domain": ".www.tiktok.com", + "expirationDate": 1793198587, + "hostOnly": false, + "httpOnly": false, + "name": "tiktok_webapp_theme_source", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "auto" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782830586.65306, + "hostOnly": false, + "httpOnly": true, + "name": "tt_chain_token", + "path": "/", + "sameSite": null, + "secure": true, + "session": false, + "storeId": null, + "value": "6deMEWrkAGUe9R0tCISIoQ==" + }, + { + "domain": ".tiktok.com", + "hostOnly": false, + "httpOnly": true, + "name": "tt_csrf_token", + "path": "/", + "sameSite": "lax", + "secure": true, + "session": true, + "storeId": null, + "value": "q0Q4ki72-I7zQB6eLbpBBaqFBGrUF_v85N9s" + }, + { + "domain": ".tiktok.com", + "expirationDate": 1782817620.645979, + "hostOnly": false, + "httpOnly": true, + "name": "uid_tt_ss", + "path": "/", + "sameSite": "no_restriction", + "secure": true, + "session": false, + "storeId": null, + "value": "44deb1e89d254f610eefd18c39ec97fa708e9c0f22c0207f7140c6ffd6c81b2c" + } +] \ No newline at end of file