SnapFeast / auth /route.py
Testys's picture
Making main changes on Tokens and other necessity
34d2fd7
raw
history blame
768 Bytes
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)