insert_longwu988_scaffold.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """Insert a SCAFFOLD longwu988 row for dev testing of B/C preconditions.
  2. WARNING: This row has a FAKE token + PLAINTEXT password.
  3. - Token is NOT valid for 996box (B1/B2/C1 will get 401).
  4. - Password IS the real one (from .env) so we can re-login when token
  5. expires. For dev only — production should encrypt the password.
  6. To get a REAL token: run A1 (manual geetest), which will overwrite
  7. this row's token via UserStore.upsert_by_username.
  8. """
  9. import sys
  10. from pathlib import Path
  11. _HERE = Path(__file__).resolve().parent
  12. sys.path.insert(0, str(_HERE.parent / "src"))
  13. from cq2_sdk.env_loader import load_env
  14. load_env(_HERE.parent / ".env")
  15. from cq2_sdk.store import UserStore, connection
  16. ACCOUNT = "longwu988"
  17. PASSWORD = "Longwu1988" # hardcoded for scaffold; real A1 reads from .env
  18. PHONE = "17756576757" # 用户的手机号 (A2 SMS 登录备用)
  19. FAKE_TOKEN = "DEV_SCAFFOLD_TOKEN_NOT_REAL_RUN_A1_TO_OVERWRITE_xxxxxxxxxxxxxxxxxxxx"
  20. with connection() as conn:
  21. users = UserStore(conn)
  22. u = users.upsert_by_username(
  23. username=ACCOUNT,
  24. token=FAKE_TOKEN,
  25. password=PASSWORD,
  26. phone=PHONE, # 一并写进 phone 字段
  27. token_expires_at=None,
  28. )
  29. print(f"[OK] upserted {ACCOUNT}: id={u.id}")
  30. print(f" username = {u.username}")
  31. print(f" phone = {u.phone}")
  32. print(f" password_hash = {u.password_hash}")
  33. print(f" token (60) = {u.token[:60]}")
  34. print()
  35. print("!!! WARNINGS !!!")
  36. print(" - token is FAKE — B1/B2/C1 will return 401 from 996box")
  37. print(" - password stored as PLAINTEXT — dev only, encrypt for prod")
  38. print(" - To get a real token: run A1 (will overwrite token, keep phone/password)")