fix: Await auth delete request before forwarding to OIDC

This commit is contained in:
Tom Moor
2024-04-02 21:57:20 -04:00
parent 40cf70d7ca
commit e0ae044f4c
2 changed files with 11 additions and 10 deletions

View File

@@ -87,8 +87,7 @@ export const navigateToSettings = createAction({
section: NavigationSection, section: NavigationSection,
shortcut: ["g", "s"], shortcut: ["g", "s"],
icon: <SettingsIcon />, icon: <SettingsIcon />,
visible: ({ stores }) => visible: () => stores.policies.abilities(stores.auth.team?.id || "").update,
stores.policies.abilities(stores.auth.team?.id || "").update,
perform: () => history.push(settingsPath()), perform: () => history.push(settingsPath()),
}); });
@@ -142,7 +141,7 @@ export const toggleSidebar = createAction({
analyticsName: "Toggle sidebar", analyticsName: "Toggle sidebar",
keywords: "hide show navigation", keywords: "hide show navigation",
section: NavigationSection, section: NavigationSection,
perform: ({ stores }) => stores.ui.toggleCollapsedSidebar(), perform: () => stores.ui.toggleCollapsedSidebar(),
}); });
export const openFeedbackUrl = createAction({ export const openFeedbackUrl = createAction({
@@ -205,8 +204,8 @@ export const logout = createAction({
analyticsName: "Log out", analyticsName: "Log out",
section: NavigationSection, section: NavigationSection,
icon: <LogoutIcon />, icon: <LogoutIcon />,
perform: () => { perform: async () => {
void stores.auth.logout(); await stores.auth.logout();
if (env.OIDC_LOGOUT_URI) { if (env.OIDC_LOGOUT_URI) {
window.location.replace(env.OIDC_LOGOUT_URI); window.location.replace(env.OIDC_LOGOUT_URI);
} }

View File

@@ -5,11 +5,13 @@ import useStores from "~/hooks/useStores";
const Logout = () => { const Logout = () => {
const { auth } = useStores(); const { auth } = useStores();
void auth.logout();
if (env.OIDC_LOGOUT_URI) { void auth.logout().then(() => {
window.location.replace(env.OIDC_LOGOUT_URI); if (env.OIDC_LOGOUT_URI) {
return null; window.location.replace(env.OIDC_LOGOUT_URI);
} }
});
return <Redirect to="/" />; return <Redirect to="/" />;
}; };