From 6e1c38876a115db7b148116580df4b70bc7e87e0 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 28 Feb 2024 20:23:59 -0500 Subject: [PATCH] fix: Publicly shared pages redirect to login --- app/actions/definitions/navigation.tsx | 4 ++++ app/scenes/Logout.tsx | 5 +++++ app/stores/AuthStore.ts | 6 ------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/actions/definitions/navigation.tsx b/app/actions/definitions/navigation.tsx index 7b2d4ff86..844dfd76b 100644 --- a/app/actions/definitions/navigation.tsx +++ b/app/actions/definitions/navigation.tsx @@ -26,6 +26,7 @@ import SearchQuery from "~/models/SearchQuery"; import KeyboardShortcuts from "~/scenes/KeyboardShortcuts"; import { createAction } from "~/actions"; import { NavigationSection, RecentSearchesSection } from "~/actions/sections"; +import env from "~/env"; import Desktop from "~/utils/Desktop"; import history from "~/utils/history"; import isCloudHosted from "~/utils/isCloudHosted"; @@ -211,6 +212,9 @@ export const logout = createAction({ icon: , perform: () => { void stores.auth.logout(); + if (env.OIDC_LOGOUT_URI) { + window.location.replace(env.OIDC_LOGOUT_URI); + } }, }); diff --git a/app/scenes/Logout.tsx b/app/scenes/Logout.tsx index 2f21dc099..32f4e27d8 100644 --- a/app/scenes/Logout.tsx +++ b/app/scenes/Logout.tsx @@ -1,10 +1,15 @@ import * as React from "react"; import { Redirect } from "react-router-dom"; +import env from "~/env"; import useStores from "~/hooks/useStores"; const Logout = () => { const { auth } = useStores(); void auth.logout(); + if (env.OIDC_LOGOUT_URI) { + window.location.replace(env.OIDC_LOGOUT_URI); + return null; + } return ; }; diff --git a/app/stores/AuthStore.ts b/app/stores/AuthStore.ts index 88f0e755b..f855b1b12 100644 --- a/app/stores/AuthStore.ts +++ b/app/stores/AuthStore.ts @@ -14,7 +14,6 @@ import { PartialWithId } from "~/types"; import { client } from "~/utils/ApiClient"; import Desktop from "~/utils/Desktop"; import Logger from "~/utils/Logger"; -import history from "~/utils/history"; import isCloudHosted from "~/utils/isCloudHosted"; import Store from "./base/Store"; @@ -353,11 +352,6 @@ export default class AuthStore extends Store { // Tell the host application we logged out, if any – allows window cleanup. if (Desktop.isElectron()) { void Desktop.bridge?.onLogout?.(); - } else if (env.OIDC_LOGOUT_URI) { - window.location.replace(env.OIDC_LOGOUT_URI); - return; } - - history.replace("/"); }; }