diff --git a/src/frontend/src/controllers/API/queries/auth/use-post-logout.ts b/src/frontend/src/controllers/API/queries/auth/use-post-logout.ts index 80aa0c15a..7164a36e8 100644 --- a/src/frontend/src/controllers/API/queries/auth/use-post-logout.ts +++ b/src/frontend/src/controllers/API/queries/auth/use-post-logout.ts @@ -1,6 +1,11 @@ import useAuthStore from "@/stores/authStore"; import { useMutationFunctionType } from "@/types/api"; +import { + IS_AUTO_LOGIN, + LANGFLOW_AUTO_LOGIN_OPTION, +} from "@/constants/constants"; +import { Cookies } from "react-cookie"; import { api } from "../../api"; import { getURL } from "../../helpers/constants"; import { UseRequestProcessor } from "../../services/request-processor"; @@ -9,10 +14,16 @@ export const useLogout: useMutationFunctionType = ( options?, ) => { const { mutate } = UseRequestProcessor(); + const cookies = new Cookies(); const logout = useAuthStore((state) => state.logout); + const isAutoLoginEnv = IS_AUTO_LOGIN; async function logoutUser(): Promise { - const autoLogin = useAuthStore.getState().autoLogin; + const autoLogin = + useAuthStore.getState().autoLogin || + cookies.get(LANGFLOW_AUTO_LOGIN_OPTION) === "auto" || + isAutoLoginEnv; + if (autoLogin) { return {}; }