fix: asyncio.create_task를 await로 수정
Some checks failed
Build and Push Images / build-backend (push) Has been cancelled

This commit is contained in:
qorgh529
2026-04-27 18:46:21 +09:00
parent 08e0195726
commit 6379f8a526

View File

@@ -158,7 +158,7 @@ class LoginRequest(BaseModel):
password: str
@app.post("/api/auth/login")
def login(req: LoginRequest, conn=Depends(get_db)):
async def login(req: LoginRequest, conn=Depends(get_db)):
cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
cur.execute("SELECT * FROM users WHERE username = %s", (req.username,))
user = cur.fetchone()
@@ -180,8 +180,7 @@ def login(req: LoginRequest, conn=Depends(get_db)):
)
conn.commit()
if locked:
import asyncio
asyncio.create_task(notify_discord_only(
await notify_discord_only(
title="🔒 계정 잠금 발생",
message=(
f"사용자: `{req.username}`\n"
@@ -189,7 +188,7 @@ def login(req: LoginRequest, conn=Depends(get_db)):
f"관리자 페이지에서 잠금 해제 또는 임시 비밀번호를 발급해주세요."
),
color=0xe74c3c
))
)
raise HTTPException(status_code=403, detail="Account locked due to too many failed attempts. Please contact admin.")
remaining = MAX_LOGIN_ATTEMPTS - attempts
raise HTTPException(status_code=401, detail=f"Invalid credentials. {remaining} attempts remaining.")
@@ -372,15 +371,14 @@ async def reset_password(user_id: int, token=Depends(require_admin), conn=Depend
)
conn.commit()
if user:
import asyncio
asyncio.create_task(notify_discord_only(
await notify_discord_only(
title="🔑 임시 비밀번호 발급",
message=(
f"관리자 `{token['username']}` 이(가) 임시 비밀번호를 발급했습니다.\n"
f"대상 사용자: `{user['username']}`"
),
color=0x3498db
))
)
return {"ok": True, "temp_password": temp_pw}
# ─── Admin: 계정 잠금 해제 ───────────────────────────────