Commit existing codebase
This commit is contained in:
commit
49bc902bb9
24 changed files with 1208 additions and 0 deletions
17
app/auth/handlers.py
Normal file
17
app/auth/handlers.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.auth.dto import Credentials, TokenModel
|
||||
from app.auth.service import authenticate
|
||||
from app.db import get_db
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/auth", status_code=200, response_model=TokenModel)
|
||||
def issue_access_token(credentials: Credentials, db: Session = Depends(get_db)) -> TokenModel:
|
||||
token = authenticate(credentials, db)
|
||||
if token is None:
|
||||
raise HTTPException(status_code=401)
|
||||
else:
|
||||
return TokenModel(token=token)
|
||||
Loading…
Add table
Add a link
Reference in a new issue