From e0ae044f4c93d144e2d797f48d2d12ffee4c9920 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 2 Apr 2024 21:57:20 -0400 Subject: [PATCH] fix: Await auth delete request before forwarding to OIDC --- app/actions/definitions/navigation.tsx | 9 ++++----- app/scenes/Logout.tsx | 12 +++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/actions/definitions/navigation.tsx b/app/actions/definitions/navigation.tsx index 8c310a250..45ef5d728 100644 --- a/app/actions/definitions/navigation.tsx +++ b/app/actions/definitions/navigation.tsx @@ -87,8 +87,7 @@ export const navigateToSettings = createAction({ section: NavigationSection, shortcut: ["g", "s"], icon: , - visible: ({ stores }) => - stores.policies.abilities(stores.auth.team?.id || "").update, + visible: () => stores.policies.abilities(stores.auth.team?.id || "").update, perform: () => history.push(settingsPath()), }); @@ -142,7 +141,7 @@ export const toggleSidebar = createAction({ analyticsName: "Toggle sidebar", keywords: "hide show navigation", section: NavigationSection, - perform: ({ stores }) => stores.ui.toggleCollapsedSidebar(), + perform: () => stores.ui.toggleCollapsedSidebar(), }); export const openFeedbackUrl = createAction({ @@ -205,8 +204,8 @@ export const logout = createAction({ analyticsName: "Log out", section: NavigationSection, icon: , - perform: () => { - void stores.auth.logout(); + perform: async () => { + await 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 32f4e27d8..600434af4 100644 --- a/app/scenes/Logout.tsx +++ b/app/scenes/Logout.tsx @@ -5,11 +5,13 @@ 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; - } + + void auth.logout().then(() => { + if (env.OIDC_LOGOUT_URI) { + window.location.replace(env.OIDC_LOGOUT_URI); + } + }); + return ; };