fix: asyncio.create_task를 await로 수정
Some checks failed
Build and Push Images / build-backend (push) Has been cancelled
Some checks failed
Build and Push Images / build-backend (push) Has been cancelled
This commit is contained in:
@@ -158,7 +158,7 @@ class LoginRequest(BaseModel):
|
|||||||
password: str
|
password: str
|
||||||
|
|
||||||
@app.post("/api/auth/login")
|
@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 = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
|
||||||
cur.execute("SELECT * FROM users WHERE username = %s", (req.username,))
|
cur.execute("SELECT * FROM users WHERE username = %s", (req.username,))
|
||||||
user = cur.fetchone()
|
user = cur.fetchone()
|
||||||
@@ -180,8 +180,7 @@ def login(req: LoginRequest, conn=Depends(get_db)):
|
|||||||
)
|
)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
if locked:
|
if locked:
|
||||||
import asyncio
|
await notify_discord_only(
|
||||||
asyncio.create_task(notify_discord_only(
|
|
||||||
title="🔒 계정 잠금 발생",
|
title="🔒 계정 잠금 발생",
|
||||||
message=(
|
message=(
|
||||||
f"사용자: `{req.username}`\n"
|
f"사용자: `{req.username}`\n"
|
||||||
@@ -189,7 +188,7 @@ def login(req: LoginRequest, conn=Depends(get_db)):
|
|||||||
f"관리자 페이지에서 잠금 해제 또는 임시 비밀번호를 발급해주세요."
|
f"관리자 페이지에서 잠금 해제 또는 임시 비밀번호를 발급해주세요."
|
||||||
),
|
),
|
||||||
color=0xe74c3c
|
color=0xe74c3c
|
||||||
))
|
)
|
||||||
raise HTTPException(status_code=403, detail="Account locked due to too many failed attempts. Please contact admin.")
|
raise HTTPException(status_code=403, detail="Account locked due to too many failed attempts. Please contact admin.")
|
||||||
remaining = MAX_LOGIN_ATTEMPTS - attempts
|
remaining = MAX_LOGIN_ATTEMPTS - attempts
|
||||||
raise HTTPException(status_code=401, detail=f"Invalid credentials. {remaining} attempts remaining.")
|
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()
|
conn.commit()
|
||||||
if user:
|
if user:
|
||||||
import asyncio
|
await notify_discord_only(
|
||||||
asyncio.create_task(notify_discord_only(
|
|
||||||
title="🔑 임시 비밀번호 발급",
|
title="🔑 임시 비밀번호 발급",
|
||||||
message=(
|
message=(
|
||||||
f"관리자 `{token['username']}` 이(가) 임시 비밀번호를 발급했습니다.\n"
|
f"관리자 `{token['username']}` 이(가) 임시 비밀번호를 발급했습니다.\n"
|
||||||
f"대상 사용자: `{user['username']}`"
|
f"대상 사용자: `{user['username']}`"
|
||||||
),
|
),
|
||||||
color=0x3498db
|
color=0x3498db
|
||||||
))
|
)
|
||||||
return {"ok": True, "temp_password": temp_pw}
|
return {"ok": True, "temp_password": temp_pw}
|
||||||
|
|
||||||
# ─── Admin: 계정 잠금 해제 ───────────────────────────────
|
# ─── Admin: 계정 잠금 해제 ───────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user