diff --git a/backend/main.py b/backend/main.py index 57fdecd..70b0936 100755 --- a/backend/main.py +++ b/backend/main.py @@ -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: 계정 잠금 ν•΄μ œ ───────────────────────────────