fix: 修复3个问题

1. 对比度: --text-muted 从 #94a3b8 改为 #c8d6e5 (文字更亮)
2. 登录: auth.py 从 .env 文件读取密码,解决后台进程环境变量丢失
3. 实例创建: 同步 instances.py 的 db import (之前缺 import db)
This commit is contained in:
Your Name
2026-07-16 18:35:03 +08:00
parent cea6c54e78
commit c8230f0d16
4 changed files with 22 additions and 6 deletions
+17 -4
View File
@@ -7,10 +7,23 @@ bp = Blueprint("auth", __name__)
def _get_admin_creds():
return (
os.environ.get("SM_ADMIN_USER", "admin"),
os.environ.get("SM_ADMIN_PASSWORD", ""),
)
import os
_ENV = "/root/socks-manager/.env"
pwd = os.environ.get("SM_ADMIN_PASSWORD")
user = os.environ.get("SM_ADMIN_USER", "admin")
if not pwd and os.path.exists(_ENV):
try:
for line in open(_ENV):
line = line.strip()
if line and not line.startswith("#"):
k, _, v = line.partition("=")
if k.strip() == "SM_ADMIN_PASSWORD":
pwd = v.strip()
elif k.strip() == "SM_ADMIN_USER":
user = v.strip()
except Exception:
pass
return (user, pwd or "")
def login_required(f):