mirror of
https://gitverse.ru/kpa39l/telepost.git
synced 2026-09-29 09:55:09 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ....database.database import get_db
|
||||
from ....auth.telegram_auth import authenticate_user_telegram
|
||||
from ....schemas.token import Token
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/telegram-login", response_model=Token)
|
||||
async def telegram_login(auth_data: Dict[str, Any], db: Session = Depends(get_db)):
|
||||
"""
|
||||
Authenticate user via Telegram Login Widget
|
||||
Expects data received from Telegram Login Widget
|
||||
"""
|
||||
result = authenticate_user_telegram(db, auth_data)
|
||||
|
||||
if not result:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Invalid Telegram login data",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
return result
|
||||
Reference in New Issue
Block a user