feat: save registered accounts to postgres
This commit is contained in:
@@ -731,7 +731,14 @@ def _post_form(
|
||||
) from exc
|
||||
|
||||
|
||||
def _build_token_result(token_payload: Dict[str, Any], account_password: str = "") -> str:
|
||||
def _build_token_result(
|
||||
token_payload: Dict[str, Any],
|
||||
account_password: str = "",
|
||||
mail_password: str = "",
|
||||
mail_token: str = "",
|
||||
name: str = "",
|
||||
birthdate: str = "",
|
||||
) -> str:
|
||||
access_token = str(token_payload.get("access_token") or "").strip()
|
||||
refresh_token = str(token_payload.get("refresh_token") or "").strip()
|
||||
id_token = str(token_payload.get("id_token") or "").strip()
|
||||
@@ -773,6 +780,14 @@ def _build_token_result(token_payload: Dict[str, Any], account_password: str = "
|
||||
}
|
||||
if account_password:
|
||||
config["account_password"] = account_password
|
||||
if mail_password:
|
||||
config["mail_password"] = mail_password
|
||||
if mail_token:
|
||||
config["mail_token"] = mail_token
|
||||
if name:
|
||||
config["name"] = name
|
||||
if birthdate:
|
||||
config["birthdate"] = birthdate
|
||||
return json.dumps(config, ensure_ascii=False, separators=(",", ":"))
|
||||
|
||||
|
||||
@@ -1321,6 +1336,8 @@ def run(
|
||||
return None
|
||||
|
||||
# ------- 步骤2:创建临时邮箱 -------
|
||||
mailbox_password = ""
|
||||
mailbox_token = ""
|
||||
if mail_provider is not None:
|
||||
emitter.info("正在创建临时邮箱...", step="create_email")
|
||||
try:
|
||||
@@ -1330,6 +1347,9 @@ def run(
|
||||
)
|
||||
except TypeError:
|
||||
email, dev_token = mail_provider.create_mailbox(proxy="")
|
||||
mailbox_info = getattr(mail_provider, "last_mailbox_info", {}) or {}
|
||||
mailbox_password = str(mailbox_info.get("mail_password") or "").strip()
|
||||
mailbox_token = str(mailbox_info.get("mail_token") or dev_token or "").strip()
|
||||
else:
|
||||
emitter.info("正在创建 Mail.tm 临时邮箱...", step="create_email")
|
||||
email, dev_token = get_email_and_token(
|
||||
@@ -1337,6 +1357,7 @@ def run(
|
||||
emitter,
|
||||
proxy_selector=None,
|
||||
)
|
||||
mailbox_token = str(dev_token or "").strip()
|
||||
if not email or not dev_token:
|
||||
emitter.error("临时邮箱创建失败", step="create_email")
|
||||
return None
|
||||
@@ -2012,7 +2033,14 @@ def run(
|
||||
emitter.success("Token 获取成功!", step="get_token")
|
||||
try: s.close()
|
||||
except: pass
|
||||
return _build_token_result(_token_json, account_password=account_password)
|
||||
return _build_token_result(
|
||||
_token_json,
|
||||
account_password=account_password,
|
||||
mail_password=mailbox_password,
|
||||
mail_token=mailbox_token,
|
||||
name=_rand_name,
|
||||
birthdate=_rand_bday,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
emitter.error(f"运行时发生错误: {e}", step="runtime")
|
||||
|
||||
Reference in New Issue
Block a user