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 ? ( - - ) : ( - - ); +return ( + <> + + + {loggedIn ? ( + + ) : ( + + )} + +); } + + + + + //export default App diff --git a/src/components/HotelContext.jsx b/src/components/HotelContext.jsx index b257652..2cde6bb 100644 --- a/src/components/HotelContext.jsx +++ b/src/components/HotelContext.jsx @@ -291,6 +291,8 @@ export function HotelProvider({ accessToken, children, resClientId}) { } + + // --- ADMIN PORTAL ---- function registerUser(username,password,hotel_ids, displayname) {