Update code in endpoints/login.post.py
This commit is contained in:
parent
903ed938be
commit
9c6d64d811
@ -2,12 +2,12 @@ from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_db
|
||||
from models.user import User
|
||||
from schemas.user import UserSchema, UserLogin
|
||||
from helpers.auth_helpers import authenticate_user, create_access_token
|
||||
from schemas.user import UserLogin, UserResponse
|
||||
from helpers.user_helpers import authenticate_user, create_access_token
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/login", status_code=200)
|
||||
@router.post("/login", status_code=200, response_model=UserResponse)
|
||||
async def login(
|
||||
user_credentials: UserLogin,
|
||||
db: Session = Depends(get_db)
|
||||
@ -21,4 +21,4 @@ async def login(
|
||||
)
|
||||
|
||||
access_token = create_access_token(data={"sub": user.username})
|
||||
return {"access_token": access_token, "token_type": "bearer"}
|
||||
return {"access_token": access_token, "token_type": "bearer", "user": user}
|
Loading…
x
Reference in New Issue
Block a user