Files
taskncoffee/src/api/v1/auth.py
2025-08-08 15:30:17 +03:00

29 lines
820 B
Python

from typing import Annotated
from fastapi import APIRouter, Depends
from fastapi.security import OAuth2PasswordRequestForm
from src.api.dependacies.db_dep import sessionDep
from src.core.settings import settings
from src.schemas.users import UserRequestADD
from src.services.auth import AuthService
router = APIRouter(prefix=settings.api.v1.auth, tags=["Auth"])
@router.post(path="/signup")
async def registration(session: sessionDep, credential: UserRequestADD):
auth = await AuthService(session).registration(credential)
return auth
@router.post(path="/login")
async def login(
session: sessionDep,
credential: Annotated[OAuth2PasswordRequestForm, Depends()],
):
access_token = await AuthService(session).login(
credential.username, credential.password
)
return access_token