forked from FOSS/Steam-Panel
v3.1.0
This commit is contained in:
+4
-1
@@ -66,7 +66,10 @@ async def generate_2fa_code(request: Generate2FARequest):
|
||||
"""Server-side 2FA code generation from shared_secret."""
|
||||
from app.services.steam_guard import generate_2fa_code as gen_code
|
||||
|
||||
code = gen_code(request.shared_secret)
|
||||
try:
|
||||
code = gen_code(request.shared_secret)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=f"Invalid shared_secret: {exc}") from exc
|
||||
return {"code": code}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.database import get_db
|
||||
from app.core.auto_confirm import auto_confirm_manager
|
||||
|
||||
router = APIRouter(prefix="/api/auto-confirm", tags=["auto-confirm"])
|
||||
|
||||
|
||||
class AutoConfirmRequest(BaseModel):
|
||||
account_ids: list[int]
|
||||
|
||||
|
||||
@router.post("/start")
|
||||
async def start_auto_confirm(body: AutoConfirmRequest):
|
||||
db = await get_db()
|
||||
started: list[int] = []
|
||||
for aid in body.account_ids:
|
||||
cursor = await db.execute("SELECT * FROM accounts WHERE id = ?", (aid,))
|
||||
row = await cursor.fetchone()
|
||||
if not row:
|
||||
raise HTTPException(404, f"Account {aid} not found")
|
||||
account = dict(row)
|
||||
if not account.get("identity_secret"):
|
||||
raise HTTPException(400, f"Account {account['login']} has no identity_secret (mafile required)")
|
||||
await auto_confirm_manager.start(account)
|
||||
await db.execute("UPDATE accounts SET auto_confirm = 1 WHERE id = ?", (aid,))
|
||||
started.append(aid)
|
||||
await db.commit()
|
||||
return {"started": started}
|
||||
|
||||
|
||||
@router.post("/stop")
|
||||
async def stop_auto_confirm(body: AutoConfirmRequest):
|
||||
db = await get_db()
|
||||
stopped: list[int] = []
|
||||
for aid in body.account_ids:
|
||||
auto_confirm_manager.stop(aid)
|
||||
await db.execute("UPDATE accounts SET auto_confirm = 0 WHERE id = ?", (aid,))
|
||||
stopped.append(aid)
|
||||
await db.commit()
|
||||
return {"stopped": stopped}
|
||||
|
||||
|
||||
@router.get("/status")
|
||||
async def auto_confirm_status():
|
||||
running = auto_confirm_manager.running_ids()
|
||||
errors = auto_confirm_manager.pop_errors()
|
||||
return {"running": list(running), "errors": errors}
|
||||
@@ -11,6 +11,10 @@ router = APIRouter(prefix="/api/settings", tags=["settings"])
|
||||
SETTINGS_FILE = settings.data_dir / "settings.json"
|
||||
|
||||
DEFAULTS = {
|
||||
"services": {
|
||||
"auto_accept_interval": 15,
|
||||
"auto_confirm_interval": 30,
|
||||
},
|
||||
"validation": {
|
||||
"fetch_profile": True,
|
||||
"check_ban": True,
|
||||
@@ -39,6 +43,8 @@ DEFAULTS = {
|
||||
"phone": True,
|
||||
"status": True,
|
||||
"ban": True,
|
||||
"vac": True,
|
||||
"limit": True,
|
||||
"twofa": True,
|
||||
"mafile": True,
|
||||
"proxy": True,
|
||||
@@ -53,6 +59,8 @@ DEFAULTS = {
|
||||
"login_pass": True,
|
||||
"status": True,
|
||||
"ban": True,
|
||||
"vac": True,
|
||||
"limit": True,
|
||||
"prime": True,
|
||||
"trophy": True,
|
||||
"behavior": True,
|
||||
@@ -69,6 +77,9 @@ DEFAULTS = {
|
||||
"login": True,
|
||||
"token": True,
|
||||
"status": True,
|
||||
"ban": True,
|
||||
"vac": True,
|
||||
"limit": True,
|
||||
"proxy": True,
|
||||
"notes": True,
|
||||
"actions": True,
|
||||
@@ -87,6 +98,11 @@ def _write(data: dict) -> None:
|
||||
SETTINGS_FILE.write_text(json.dumps(data, indent=2, ensure_ascii=False), "utf-8")
|
||||
|
||||
|
||||
class ServicesSettings(BaseModel):
|
||||
auto_accept_interval: int = 15
|
||||
auto_confirm_interval: int = 30
|
||||
|
||||
|
||||
class ValidationSettings(BaseModel):
|
||||
fetch_profile: bool = True
|
||||
check_ban: bool = True
|
||||
@@ -117,6 +133,8 @@ class ColumnSettings(BaseModel):
|
||||
phone: bool = True
|
||||
status: bool = True
|
||||
ban: bool = True
|
||||
vac: bool = True
|
||||
limit: bool = True
|
||||
twofa: bool = True
|
||||
mafile: bool = True
|
||||
proxy: bool = True
|
||||
@@ -124,6 +142,20 @@ class ColumnSettings(BaseModel):
|
||||
last_online: bool = True
|
||||
|
||||
|
||||
@router.get("/services", response_model=ServicesSettings)
|
||||
async def get_services_settings():
|
||||
data = _read()
|
||||
return data.get("services", DEFAULTS["services"])
|
||||
|
||||
|
||||
@router.put("/services", response_model=ServicesSettings)
|
||||
async def update_services_settings(body: ServicesSettings):
|
||||
data = _read()
|
||||
data["services"] = body.model_dump()
|
||||
_write(data)
|
||||
return data["services"]
|
||||
|
||||
|
||||
@router.get("/validation", response_model=ValidationSettings)
|
||||
async def get_validation_settings():
|
||||
data = _read()
|
||||
@@ -175,6 +207,8 @@ class LogpassColumnSettings(BaseModel):
|
||||
login_pass: bool = True
|
||||
status: bool = True
|
||||
ban: bool = True
|
||||
vac: bool = True
|
||||
limit: bool = True
|
||||
prime: bool = True
|
||||
trophy: bool = True
|
||||
behavior: bool = True
|
||||
@@ -207,6 +241,9 @@ class TokenColumnSettings(BaseModel):
|
||||
login: bool = True
|
||||
token: bool = True
|
||||
status: bool = True
|
||||
ban: bool = True
|
||||
vac: bool = True
|
||||
limit: bool = True
|
||||
proxy: bool = True
|
||||
notes: bool = True
|
||||
actions: bool = True
|
||||
|
||||
Reference in New Issue
Block a user