From f714d416b1ad51bd5fbd839ca5dfba8f04b151a4 Mon Sep 17 00:00:00 2001 From: "Cpt.KK" <55737933+CPT-KK@users.noreply.github.com> Date: Sun, 7 Apr 2024 14:34:02 +0800 Subject: [PATCH] Follow rules by ITC to obtain the acid value (#49) Co-authored-by: CptKKKK Co-authored-by: Y.D.X <73375426+YDX-2147483647@users.noreply.github.com> --- src/bitsrun/user.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bitsrun/user.py b/src/bitsrun/user.py index 35710d1..cd5216b 100644 --- a/src/bitsrun/user.py +++ b/src/bitsrun/user.py @@ -45,9 +45,17 @@ def __init__(self, username: str, password: str): # Initialize reused httpx client self.client = httpx.Client(base_url=_API_BASE) - # Get `ac_id` from the redirected login page + # Visit another site using HTTP, and let srun redirect to 10.0.0.55 + # with url params (ac_id, theme, wlanuserip, etc.) + # but better to check since the user may have been authenticated resp = self.client.get('/', follow_redirects=True) - self.acid = resp.url.params.get('ac_id') + resp_valid = httpx.Client(base_url='http://www.bit.edu.cn').get( + '/', follow_redirects=True + ) + if resp_valid.url.params.get('ac_id') is None: + self.acid = resp.url.params.get('ac_id') + else: + self.acid = resp_valid.url.params.get('ac_id') # Check current login status and get device `online_ip` login_status = get_login_status(client=self.client)