| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/usr/bin/env python3
- """Reset UAT admin passwords, then continue existing WP-SD7 drafts. Do not commit."""
- from __future__ import annotations
- import os
- import sys
- from pathlib import Path
- os.environ.setdefault("AIDOP_API_BASE", "http://127.0.0.1:5005")
- HERE = Path(__file__).resolve().parent
- sys.path.insert(0, str(HERE))
- from run_wp_sd7_api_loop import TENANTS, login, request, unwrap # noqa: E402
- from _tmp_sd7_continue_drafts import main as continue_main # noqa: E402
- SUPER_CIPHER = os.environ.get("AIDOP_SUPER_CIPHER", "").strip()
- if not SUPER_CIPHER:
- raise SystemExit("AIDOP_SUPER_CIPHER required")
- def reset_password(super_token: str, user_id: str) -> str:
- status, body = request("POST", "/api/sysUser/resetPwd", {"id": int(user_id)}, super_token)
- pwd = unwrap(body)
- if status != 200 or not isinstance(pwd, str) or not pwd:
- raise SystemExit(f"resetPwd failed for {user_id}: HTTP {status}")
- return pwd
- def main() -> None:
- super_token = login("superAdmin.NET", "1300000000001", SUPER_CIPHER, already_encrypted=True)
- passwords = {}
- for code, meta in TENANTS.items():
- passwords[code] = reset_password(super_token, meta["user_id"])
- print("reset_ok", code, meta["account"])
- for code in TENANTS:
- os.environ["AIDOP_UAT_PASSWORD"] = passwords[code]
- os.environ["AIDOP_UAT_TENANT"] = code
- continue_main()
- if __name__ == "__main__":
- main()
|