Update code in endpoints/logout.post.py
This commit is contained in:
parent
7cec306853
commit
de1d097341
@ -1,15 +1,17 @@
|
|||||||
# Entity: User
|
# Entity: User
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from fastapi.security import OAuth2PasswordBearer
|
from sqlalchemy.orm import Session
|
||||||
|
from core.database import get_db
|
||||||
from models.user import User
|
from models.user import User
|
||||||
from schemas.user import UserSchema
|
from schemas.user import UserSchema
|
||||||
|
from helpers.user_helpers import logout_user
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
|
||||||
|
|
||||||
@router.post("/logout", status_code=status.HTTP_200_OK)
|
@router.post("/logout", status_code=200)
|
||||||
async def logout(token: str = Depends(oauth2_scheme)):
|
async def logout(
|
||||||
# Implement logout logic here
|
db: Session = Depends(get_db)
|
||||||
# For example, invalidate the token or remove it from the cache
|
):
|
||||||
return {"message": "Logout successful"}
|
logout_user(db)
|
||||||
|
return {"message": "Logged out successfully"}
|
Loading…
x
Reference in New Issue
Block a user