TOTP endpoint update - support sending code that's less than or equal to 10 chars directly (#2464)

This commit is contained in:
Shuchang Zheng
2025-05-26 13:28:20 -07:00
committed by GitHub
parent 2fb4c8222b
commit c11fb425e3

View File

@@ -69,8 +69,20 @@ async def send_totp_code(
task_id=data.task_id,
workflow_id=data.workflow_id,
)
code = await parse_totp_code(data.content)
content = data.content.strip()
code: str | None = content
# We assume the user is sending the code directly when the length of code is less than or equal to 10
if len(content) > 10:
code = await parse_totp_code(content)
if not code:
LOG.error(
"Failed to parse totp code",
totp_identifier=data.totp_identifier,
task_id=data.task_id,
workflow_id=data.workflow_id,
workflow_run_id=data.workflow_run_id,
content=data.content,
)
raise HTTPException(status_code=400, detail="Failed to parse totp code")
return await app.DATABASE.create_totp_code(
organization_id=curr_org.organization_id,