diff --git a/src/App.jsx b/src/App.jsx index 97f2d4d..00d3a51 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -51,15 +51,51 @@ async function checkAuth() { } } +async function logoutUser() { + + try { + const res = await fetch(`${API_BASE}/auth/logout_single_device`, { + method: "POST", + headers: { + "Content-Type": "application/json", + "User-Agent": "react-app", + }, + credentials: "include", // send cookies automatically + body: JSON.stringify({ + device_id : "147ac10b-58cc-4372-a567-0e02b2c3d479", // or persistent device ID + }), + }); + + const data = await res.json(); + + localStorage.setItem("access_tokens", JSON.stringify(data.tokens)); + + setClientId(data.user_id); + setLoggedIn(false); + } finally { + checkAuth(); + } +} + if (loading) return
Loading...
; // can show a spinner - // Show main app if logged in, otherwise show login - return loggedIn ? ( -