feat: service token introduction
This commit is contained in:
17
core/auth/fetch_sub.py
Normal file
17
core/auth/fetch_sub.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from db.models import User
|
||||
from repositories.users import UserRepository
|
||||
from schemas.jwt import ServiceJWTPayload
|
||||
|
||||
|
||||
async def fetch_subject_from_service(
|
||||
payload: ServiceJWTPayload, session: AsyncSession
|
||||
) -> User | None:
|
||||
repo = UserRepository(session)
|
||||
|
||||
if payload.acting_as.startswith("telegram:"):
|
||||
telegram_id = int(payload.acting_as.split("telegram:")[1])
|
||||
return await repo.get_user_by_telegram_id(telegram_id)
|
||||
|
||||
return
|
||||
Reference in New Issue
Block a user