Przeglądaj źródła

fix(mail): 邮件验证码 demo 判断与 PL_DEMO 解耦,Resend 已配置即真实发信

PL_DEMO=1 仍用于无真实通道的短信演示登录;邮件通道独立按 smtp_configured() 判断,
避免生产环境邮件验证码随接口返回。
wenhongquan 1 miesiąc temu
rodzic
commit
c63ad91720
1 zmienionych plików z 3 dodań i 1 usunięć
  1. 3 1
      server/auth.py

+ 3 - 1
server/auth.py

@@ -228,7 +228,9 @@ def issue_email_code(email: str) -> dict:
             (email, code, now, now + SMS_TTL),
         )
         cur.execute("DELETE FROM email_codes WHERE expires_at < %s", (now - SMS_TTL,))
-    demo = DEMO_MODE or not email_service.smtp_configured()
+    # 邮件演示模式只取决于真实邮件通道(Resend/SMTP)是否配置,
+    # 与短信通道的 PL_DEMO 解耦:生产已接 Resend,邮件验证码必须真实发送。
+    demo = not email_service.smtp_configured()
     result = {"ok": True, "demo": demo}
     if demo:
         result["code"] = code