Add hub settings tabs and account password change UI.
Restructure manual-trading-hub settings with CSS tabs matching instance layout; add password API writing HUB_USERNAME/HUB_PASSWORD to hub .env. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1650,6 +1650,48 @@ def api_settings_meta():
|
||||
}
|
||||
|
||||
|
||||
class HubPasswordBody(BaseModel):
|
||||
old_password: str = ""
|
||||
new_username: str = ""
|
||||
new_password: str = ""
|
||||
confirm_password: str = ""
|
||||
|
||||
|
||||
@app.post("/api/settings/password")
|
||||
def api_change_hub_password(body: HubPasswordBody):
|
||||
from hub_env_lib import update_hub_credentials
|
||||
|
||||
if not verify_credentials(expected_username(), body.old_password):
|
||||
raise HTTPException(status_code=400, detail="当前密码错误")
|
||||
if len(body.new_password or "") < 6:
|
||||
raise HTTPException(status_code=400, detail="新密码至少 6 位")
|
||||
if body.new_password != body.confirm_password:
|
||||
raise HTTPException(status_code=400, detail="两次输入的新密码不一致")
|
||||
new_user = (body.new_username or "").strip()
|
||||
changed = update_hub_credentials(
|
||||
new_password=body.new_password,
|
||||
new_username=new_user or None,
|
||||
)
|
||||
if not changed:
|
||||
return {"ok": True, "changed_keys": [], "restart_required": False}
|
||||
return {"ok": True, "changed_keys": changed, "restart_required": True}
|
||||
|
||||
|
||||
@app.get("/api/admin/health")
|
||||
def api_admin_health():
|
||||
return {"ok": True, "status": "up"}
|
||||
|
||||
|
||||
@app.post("/api/admin/restart")
|
||||
def api_admin_restart():
|
||||
from hub_env_lib import restart_hub_pm2
|
||||
|
||||
result = restart_hub_pm2()
|
||||
if not result.get("ok"):
|
||||
raise HTTPException(status_code=500, detail=result.get("msg") or "restart failed")
|
||||
return result
|
||||
|
||||
|
||||
async def _fetch_agent_status(client: httpx.AsyncClient, ex: dict) -> dict:
|
||||
url = f"{ex['agent_url'].rstrip('/')}/status"
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user