diff --git a/src/react-components/auth/AuthContext.js b/src/react-components/auth/AuthContext.js index e5344e785f..24d310e228 100644 --- a/src/react-components/auth/AuthContext.js +++ b/src/react-components/auth/AuthContext.js @@ -5,7 +5,7 @@ import configs from "../../utils/configs"; // TODO: We really shouldn't include these dependencies on every page. A dynamic import would work better. import jwtDecode from "jwt-decode"; import AuthChannel from "../../utils/auth-channel"; -import { connectToReticulum } from "../../utils/phoenix-utils"; +import { connectToReticulum, getReticulumFetchUrl, fetchReticulumAuthenticated } from "../../utils/phoenix-utils"; export const AuthContext = createContext(); @@ -65,6 +65,7 @@ export function AuthContextProvider({ children, store }) { const socket = await connectToReticulum(); authChannel.setSocket(socket); await authChannel.verifyAuthentication(authParams.topic, authParams.token, authParams.payload); + await fetchReticulumAuthenticated("/api/v1/accounts/set_cookie", "POST"); }, [store] ); @@ -74,6 +75,9 @@ export function AuthContextProvider({ children, store }) { configs.setIsAdmin(false); store.update({ credentials: { token: null, email: null } }); await store.resetToRandomDefaultAvatar(); + await fetch(getReticulumFetchUrl("/api/v1/accounts/expire_cookie"), { + method: "POST" + }); }, [store] );