File size: 768 Bytes
998e17b 34d2fd7 998e17b 34d2fd7 d8be4a2 998e17b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from fastapi import APIRouter, status, Depends, Header
from fastapi.security import OAuth2PasswordRequestForm
from sqlalchemy.orm import Session
from core.database import get_db
from auth.services import get_refresh_token, get_token
router = APIRouter(
prefix="/auth",
tags=["Authentication"],
responses={404: {"description": "Not found"}},
)
@router.post("/token/", status_code=status.HTTP_200_OK)
async def authenticate_user(data: OAuth2PasswordRequestForm = Depends(), db: Session = Depends(get_db)):
return await get_token(data, db)
@router.post("/refresh/", status_code=status.HTTP_200_OK)
async def refresh_token(refresh_token: str = Header(...), db: Session = Depends(get_db)):
return await get_refresh_token(token=refresh_token, db=db)
|