Update code in endpoints/logout.post.py
This commit is contained in:
parent
0b893aea04
commit
28098d5be5
@ -1,17 +1,19 @@
|
|||||||
# Entity: User
|
# Entity: User
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, status
|
from fastapi import APIRouter, Depends, status
|
||||||
|
from fastapi.security import OAuth2PasswordBearer
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from core.database import get_db
|
from core.database import get_db
|
||||||
from models.user import User
|
from schemas.user import UserToken
|
||||||
from schemas.user import UserSchema
|
|
||||||
from helpers.user_helpers import logout_user
|
from helpers.user_helpers import logout_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
||||||
|
|
||||||
@router.post("/logout", status_code=200)
|
@router.post("/logout", status_code=200)
|
||||||
async def logout(
|
async def logout(
|
||||||
|
token: str = Depends(oauth2_scheme),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
logout_user(db)
|
logout_user(token, db)
|
||||||
return {"message": "Successfully logged out"}
|
return {"message": "Logout successful"}
|
Loading…
x
Reference in New Issue
Block a user