fix(login): 中文提示登录批次账号上限
This commit is contained in:
@@ -22,7 +22,7 @@ from ..deps import authenticate_websocket, get_current_user, require_permission
|
||||
from ..models import Account, LoginTask, User
|
||||
from ..models import ProxyConfig as ProxyConfigModel
|
||||
from ..permissions import get_user_permissions, user_has_permission
|
||||
from ..schemas import LoginBatchRequest, LoginTaskOut
|
||||
from ..schemas import LOGIN_BATCH_MAX_ACCOUNTS, LoginBatchRequest, LoginTaskOut
|
||||
from ..services.audit_service import record_audit
|
||||
from ..services.login_failure import classify_failure, failure_kind_label
|
||||
from ..services.login_service import LoginBatchRunner, batch_registry
|
||||
@@ -150,6 +150,14 @@ async def create_batch(
|
||||
current: User = Depends(require_permission("login:batch")),
|
||||
):
|
||||
"""创建批量登录或账号检测任务。"""
|
||||
if len(req.account_ids) > LOGIN_BATCH_MAX_ACCOUNTS:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=(
|
||||
f"单次最多选择 {LOGIN_BATCH_MAX_ACCOUNTS} 个账号,"
|
||||
f"当前选择了 {len(req.account_ids)} 个,请分批操作"
|
||||
),
|
||||
)
|
||||
if not req.account_ids:
|
||||
raise HTTPException(status_code=400, detail="请选择账号")
|
||||
|
||||
|
||||
@@ -363,8 +363,13 @@ class AccountOut(BaseModel):
|
||||
|
||||
|
||||
# ---- 登录任务 ----
|
||||
LOGIN_BATCH_MAX_ACCOUNTS = 50
|
||||
|
||||
|
||||
class LoginBatchRequest(BaseModel):
|
||||
account_ids: list[int] = Field(..., min_length=1, max_length=50)
|
||||
# 上限由路由返回中文业务提示;这里保留更大的硬上限,避免直接暴露
|
||||
# Pydantic 英文 "List should have at most ... items" 给前端。
|
||||
account_ids: list[int] = Field(..., min_length=1, max_length=500)
|
||||
max_login_retries: int = Field(0, ge=0)
|
||||
max_total_time: float = Field(300, ge=0)
|
||||
concurrency: int = Field(3, ge=1, le=10)
|
||||
|
||||
Reference in New Issue
Block a user