diff --git a/security.py b/security.py index a88b271..83e4ab7 100644 --- a/security.py +++ b/security.py @@ -111,7 +111,7 @@ async def get_current_user(security_scopes: SecurityScopes, request: Request): except ExpiredSignatureError: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, - detail="Token expired", + detail="Access token expired", headers={"WWW-Authenticate": authenticate_value}, ) except (InvalidTokenError, ValidationError): @@ -164,7 +164,7 @@ async def login_for_access_token( async def logout(response: Response): response.set_cookie("access_token", "", expires=0, httponly=True, samesite="strict") - return + return {"message": "Successfully logged out"} async def read_users_me( diff --git a/src/Avatar.tsx b/src/Avatar.tsx index 41ca04f..ed664c2 100644 --- a/src/Avatar.tsx +++ b/src/Avatar.tsx @@ -1,6 +1,5 @@ import { MouseEventHandler, useEffect, useState } from "react"; import { useSession } from "./Session"; -import { logout } from "./api"; interface ContextMenuItem { label: string; @@ -18,7 +17,7 @@ export default function Avatar() { const contextMenuItems: ContextMenuItem[] = [ { label: "View Profile", onClick: () => console.log("View Profile") }, { label: "Edit Profile", onClick: () => console.log("Edit Profile") }, - { label: "Logout", onClick: onLogout }, + { label: "Logout", onClick: () => onLogout() }, ]; const handleMenuClick: MouseEventHandler = (event) => { diff --git a/src/Footer.tsx b/src/Footer.tsx index a513478..bc1a638 100644 --- a/src/Footer.tsx +++ b/src/Footer.tsx @@ -1,23 +1,27 @@ import { useLocation } from "react-router"; import { Link } from "react-router"; +import { useSession } from "./Session"; export default function Footer() { const location = useLocation(); + const { user } = useSession(); return (