From c36e1152f131ae86218ade1dddbf8e0846d33767 Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Tue, 22 Oct 2024 02:41:16 +0900 Subject: [PATCH] fix: set email footer from $SITE_ORIGIN (#25) * set email footer from $SITE_ORIGIN --- .env.sample | 1 + .env.test.sample | 1 + app/config.py | 1 + app/models/v_code.py | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index 9e95f9d..2d468ab 100644 --- a/.env.sample +++ b/.env.sample @@ -3,6 +3,7 @@ # 【请修改】在导出文件及邮件中显示 SITE_NAME=萌翻local +SITE_ORIGIN=https://change-me.com # 【请修改】用于加密用户 session,请配置一个很长的密钥,建议配置为 64 位以上字母数字组成的密钥 # 可用使用 python -c 'import secrets; print(secrets.token_hex())' 命令来随机生成一个 SECRET_KEY=CHANGE_ME diff --git a/.env.test.sample b/.env.test.sample index c3f750e..a817a17 100644 --- a/.env.test.sample +++ b/.env.test.sample @@ -2,6 +2,7 @@ TESTING=YES LOG_LEVEL=DEBUG SITE_NAME=萌翻TEST +SITE_ORIGIN=https://test.moeflow.org SECRET_KEY=SECRET ADMIN_EMAIL=admin@moeflow.com diff --git a/app/config.py b/app/config.py index f04e037..54a645b 100644 --- a/app/config.py +++ b/app/config.py @@ -9,6 +9,7 @@ # 基础设置 # ----------- SITE_NAME = env["SITE_NAME"] +SITE_ORIGIN = env["SITE_ORIGIN"] SECRET_KEY = env["SECRET_KEY"] # 必填 - 密钥 LOG_LEVEL = env.get("LOG_LEVEL", "INFO") # DEPRECATED: please use modern container logging collector diff --git a/app/models/v_code.py b/app/models/v_code.py index 70817e0..11f2e5c 100644 --- a/app/models/v_code.py +++ b/app/models/v_code.py @@ -322,7 +322,7 @@ def to_email(self, address: str) -> None: template_data={ "code": self.content, "site_name": current_app.config.get("SITE_NAME"), - "site_url": f'https://{current_app.config.get("DOMAIN")}', + "site_url": current_app.config.get("SITE_ORIGIN"), }, ) self.send_time = datetime.datetime.utcnow()