fix(scrapers): bad credentials detection and error message cleanup
Problem: Wrong credentials during login produced two bugs: scrapers wrapped the `bad_credentials` error code in `"Login failed: ..."`, causing double-prefixed messages in the UI; and `credentials.lua` did not clear cached credentials before re-prompting or on failure, leaving stale bad creds in the cache. Solution: Standardize all scrapers to emit `"bad_credentials"` as the raw error code. Add `LOGIN_ERRORS` map in `constants.lua` to translate it to a human-readable string in both `credentials.lua` and `submit.lua`. Fix `credentials.lua` to clear credentials on failure in both the fresh-prompt and cached-creds-fail paths. For AtCoder and Codeforces, replace `wait_for_url` with `wait_for_function` to detect the login error element immediately rather than waiting the full 10s navigation timeout. Also add "Remember me" checkbox check on Codeforces login.
This commit is contained in:
parent
573b335646
commit
0ad7a9614f
9 changed files with 55 additions and 25 deletions
|
|
@ -439,7 +439,7 @@ class USACOScraper(BaseScraper):
|
|||
except Exception as e:
|
||||
return self._submit_error(f"Login failed: {e}")
|
||||
if not ok:
|
||||
return self._submit_error("Login failed (bad credentials?)")
|
||||
return self._submit_error("bad_credentials")
|
||||
await _save_usaco_cookies(client)
|
||||
else:
|
||||
print(json.dumps({"status": "logging_in"}), flush=True)
|
||||
|
|
@ -448,7 +448,7 @@ class USACOScraper(BaseScraper):
|
|||
except Exception as e:
|
||||
return self._submit_error(f"Login failed: {e}")
|
||||
if not ok:
|
||||
return self._submit_error("Login failed (bad credentials?)")
|
||||
return self._submit_error("bad_credentials")
|
||||
await _save_usaco_cookies(client)
|
||||
|
||||
result = await self._do_submit(client, problem_id, language_id, source)
|
||||
|
|
@ -463,7 +463,7 @@ class USACOScraper(BaseScraper):
|
|||
except Exception as e:
|
||||
return self._submit_error(f"Login failed: {e}")
|
||||
if not ok:
|
||||
return self._submit_error("Login failed (bad credentials?)")
|
||||
return self._submit_error("bad_credentials")
|
||||
await _save_usaco_cookies(client)
|
||||
|
||||
return await self._do_submit(client, problem_id, language_id, source)
|
||||
|
|
@ -543,7 +543,7 @@ class USACOScraper(BaseScraper):
|
|||
return self._login_error(f"Login request failed: {e}")
|
||||
|
||||
if not ok:
|
||||
return self._login_error("Login failed (bad credentials?)")
|
||||
return self._login_error("bad_credentials")
|
||||
|
||||
await _save_usaco_cookies(client)
|
||||
return LoginResult(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue