diff --git a/user_api/user_api.py b/user_api/user_api.py index ded59c4..f6e29bf 100644 --- a/user_api/user_api.py +++ b/user_api/user_api.py @@ -81,7 +81,7 @@ async def get_user_token_info_api( user_token: str = Body(), 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') user_token_db = await user_token_in_db_func(session, user_token) if not user_token_db: @@ -97,7 +97,7 @@ async def user_in_db_api( user_token: str = Body(), 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') await log(session, user_token, f'/user_in_db') return await user_in_db(token=SYSTEM_API_TOKEN, username=username) @@ -110,7 +110,7 @@ async def transfer_coins_api( amount: float = Body(), 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') 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 @@ -122,7 +122,7 @@ async def get_stats_api( user_token: str = Body(), 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') await log(session, user_token, f'/get_stats') return await get_stats(token=SYSTEM_API_TOKEN) @@ -134,7 +134,7 @@ async def create_invoice_api( amount: float | None = Body(None), 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') await log(session, user_token, f'/create_invoice: (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(), 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') await log(session, user_token, f'/delete_invoice: (id: {id})') return await delete_invoice(token=SYSTEM_API_TOKEN, id=id) @@ -158,7 +158,7 @@ async def get_invoice_api( id: str = Body(), 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') await log(session, user_token, f'/get_invoice: (id: {id})') return await get_invoice(token=SYSTEM_API_TOKEN, id=id)