feat: 管理面板(登录认证+触发AI分析+统计+CLI改密码)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""管理密码设置工具
|
||||
|
||||
用法:
|
||||
python3 admin_cli.py # 首次设置密码
|
||||
python3 admin_cli.py <新密码> # 修改密码
|
||||
python3 admin_cli.py --check # 检查是否已设置密码
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
|
||||
# 添加 backend 目录到 path
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
from services.admin_auth import is_configured, set_password
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "--check":
|
||||
if is_configured():
|
||||
print("✅ 管理密码已设置")
|
||||
else:
|
||||
print("⚠️ 管理密码未设置,请运行: python3 admin_cli.py")
|
||||
return
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
new_password = sys.argv[1]
|
||||
else:
|
||||
import getpass
|
||||
if is_configured():
|
||||
print("修改管理密码")
|
||||
else:
|
||||
print("设置管理密码")
|
||||
new_password = getpass.getpass("请输入密码: ")
|
||||
confirm = getpass.getpass("请再次输入密码: ")
|
||||
if new_password != confirm:
|
||||
print("❌ 两次输入不一致")
|
||||
sys.exit(1)
|
||||
|
||||
if len(new_password) < 4:
|
||||
print("❌ 密码至少4位")
|
||||
sys.exit(1)
|
||||
|
||||
set_password(new_password)
|
||||
print(f"✅ 管理密码已{'更新' if is_configured() else '设置'}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user