Исправление бага: await token_check

This commit is contained in:
justuser-31 2025-11-07 22:52:31 +03:00
parent 11ab54ad46
commit 602d40be59

View File

@ -81,7 +81,7 @@ async def get_user_token_info_api(
user_token: str = Body(), user_token: str = Body(),
session: AsyncSession = Depends(get_session) session: AsyncSession = Depends(get_session)
): ):
if not token_check(username, user_token): if not await token_check(username, user_token):
raise HTTPException(status_code=401, detail='Invalid username or token') raise HTTPException(status_code=401, detail='Invalid username or token')
user_token_db = await user_token_in_db_func(session, user_token) user_token_db = await user_token_in_db_func(session, user_token)
if not user_token_db: if not user_token_db:
@ -97,7 +97,7 @@ async def user_in_db_api(
user_token: str = Body(), user_token: str = Body(),
session: AsyncSession = Depends(get_session) session: AsyncSession = Depends(get_session)
): ):
if not token_check(username, user_token): if not await token_check(username, user_token):
raise HTTPException(status_code=401, detail='Invalid username or token') raise HTTPException(status_code=401, detail='Invalid username or token')
await log(session, user_token, f'/user_in_db') await log(session, user_token, f'/user_in_db')
return await user_in_db(token=SYSTEM_API_TOKEN, username=username) return await user_in_db(token=SYSTEM_API_TOKEN, username=username)
@ -110,7 +110,7 @@ async def transfer_coins_api(
amount: float = Body(), amount: float = Body(),
session: AsyncSession = Depends(get_session) session: AsyncSession = Depends(get_session)
): ):
if not token_check(username, user_token): if not await token_check(username, user_token):
raise HTTPException(status_code=401, detail='Invalid username or token') raise HTTPException(status_code=401, detail='Invalid username or token')
await log(session, user_token, f'/transfer_coins: (dst_username: {dst_username}, amount: {amount})') await log(session, user_token, f'/transfer_coins: (dst_username: {dst_username}, amount: {amount})')
return await transfer_coins(token=SYSTEM_API_TOKEN, src_username=username return await transfer_coins(token=SYSTEM_API_TOKEN, src_username=username
@ -122,7 +122,7 @@ async def get_stats_api(
user_token: str = Body(), user_token: str = Body(),
session: AsyncSession = Depends(get_session) session: AsyncSession = Depends(get_session)
): ):
if not token_check(username, user_token): if not await token_check(username, user_token):
raise HTTPException(status_code=401, detail='Invalid username or token') raise HTTPException(status_code=401, detail='Invalid username or token')
await log(session, user_token, f'/get_stats') await log(session, user_token, f'/get_stats')
return await get_stats(token=SYSTEM_API_TOKEN) return await get_stats(token=SYSTEM_API_TOKEN)
@ -134,7 +134,7 @@ async def create_invoice_api(
amount: float | None = Body(None), amount: float | None = Body(None),
session: AsyncSession = Depends(get_session) session: AsyncSession = Depends(get_session)
): ):
if not token_check(username, user_token): if not await token_check(username, user_token):
raise HTTPException(status_code=401, detail='Invalid username or token') raise HTTPException(status_code=401, detail='Invalid username or token')
await log(session, user_token, f'/create_invoice: (amount: {amount})') await log(session, user_token, f'/create_invoice: (amount: {amount})')
return await create_invoice(token=SYSTEM_API_TOKEN, dst_username=username, amount=amount) return await create_invoice(token=SYSTEM_API_TOKEN, dst_username=username, amount=amount)
@ -146,7 +146,7 @@ async def delete_invoice_api(
id: str = Body(), id: str = Body(),
session: AsyncSession = Depends(get_session) session: AsyncSession = Depends(get_session)
): ):
if not token_check(username, user_token): if not await token_check(username, user_token):
raise HTTPException(status_code=401, detail='Invalid username or token') raise HTTPException(status_code=401, detail='Invalid username or token')
await log(session, user_token, f'/delete_invoice: (id: {id})') await log(session, user_token, f'/delete_invoice: (id: {id})')
return await delete_invoice(token=SYSTEM_API_TOKEN, id=id) return await delete_invoice(token=SYSTEM_API_TOKEN, id=id)
@ -158,7 +158,7 @@ async def get_invoice_api(
id: str = Body(), id: str = Body(),
session: AsyncSession = Depends(get_session) session: AsyncSession = Depends(get_session)
): ):
if not token_check(username, user_token): if not await token_check(username, user_token):
raise HTTPException(status_code=401, detail='Invalid username or token') raise HTTPException(status_code=401, detail='Invalid username or token')
await log(session, user_token, f'/get_invoice: (id: {id})') await log(session, user_token, f'/get_invoice: (id: {id})')
return await get_invoice(token=SYSTEM_API_TOKEN, id=id) return await get_invoice(token=SYSTEM_API_TOKEN, id=id)