fix token

This commit is contained in:
cheykrym 2026-03-26 05:09:16 +03:00
parent b1f02f46f3
commit 83b8b932b1
2 changed files with 6 additions and 4 deletions

View File

@ -26,6 +26,7 @@ async def _fetch_current_user(
# credentials: HTTPAuthorizationCredentials, # credentials: HTTPAuthorizationCredentials,
token: str, token: str,
require_permissions: bool, require_permissions: bool,
is_web=bool,
is_bot=False is_bot=False
) -> CurrentUser: ) -> CurrentUser:
ip = request.client.host or "(unknown)" ip = request.client.host or "(unknown)"
@ -40,7 +41,8 @@ async def _fetch_current_user(
"ip": ip, "ip": ip,
"user_agent": user_agent, "user_agent": user_agent,
"require_permissions": require_permissions, "require_permissions": require_permissions,
"is_bot": is_bot "is_bot": is_bot,
"is_web": is_web
}, },
) )
except httpx.RequestError as e: except httpx.RequestError as e:
@ -201,7 +203,7 @@ async def get_current_user_with_permissions(
detail="Not authenticated" detail="Not authenticated"
) )
return await _fetch_current_user(request, token, require_permissions=True) return await _fetch_current_user(request, token, require_permissions=True, is_web=is_web)
async def get_current_user_or_bot( async def get_current_user_or_bot(
@ -225,7 +227,7 @@ async def get_current_user_or_bot(
) )
is_bot_flag = str(is_bot).lower() in ("true", "1", "yes") if is_bot else False is_bot_flag = str(is_bot).lower() in ("true", "1", "yes") if is_bot else False
return await _fetch_current_user(request, token, require_permissions=False, is_bot=is_bot_flag) return await _fetch_current_user(request, token, require_permissions=False, is_bot=is_bot_flag, is_web=is_web)
def validate_username(value: str, def validate_username(value: str,

View File

@ -1,6 +1,6 @@
[project] [project]
name = "common-lib" name = "common-lib"
version = "0.0.47" version = "0.0.48"
description = "Библиотека общих компонентов для микросервисов yobble" description = "Библиотека общих компонентов для микросервисов yobble"
authors = [{ name = "cheykrym", email = "you@example.com" }] authors = [{ name = "cheykrym", email = "you@example.com" }]
license = "MIT" license = "MIT"