From d8f7fa36e19e26fa2260ff203c9551ed459c52b6 Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Wed, 2 Nov 2022 11:53:42 +0100 Subject: [PATCH] make logout redirect a env var --- public/env.js | 1 + src/components/Header/HeaderLIT.tsx | 8 +++----- src/services/auth/redux/actions.ts | 5 +++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/env.js b/public/env.js index d47bfbb..1421897 100644 --- a/public/env.js +++ b/public/env.js @@ -1,3 +1,4 @@ window.env = { REACT_APP_API_URL: 'http://localhost:5000/api/v1', + REACT_APP_SSO_LOGOUT_URL: 'https://login.example.org/if/flow/default-invalidation-flow/' }; diff --git a/src/components/Header/HeaderLIT.tsx b/src/components/Header/HeaderLIT.tsx index d385158..a1f725d 100644 --- a/src/components/Header/HeaderLIT.tsx +++ b/src/components/Header/HeaderLIT.tsx @@ -10,7 +10,8 @@ import _ from 'lodash'; import { UserModal } from '../UserModal'; -const HYDRA_LOGOUT_URL = `${process.env.REACT_APP_HYDRA_PUBLIC_URL}/oauth2/sessions/logout`; +// @ts-ignore +const HYDRA_LOGOUT_URL = window.env.REACT_APP_SSO_LOGOUT_URL; const navigation = [ { name: 'Dashboard', to: '/dashboard', requiresAdmin: false }, @@ -56,10 +57,7 @@ const HeaderLIT: React.FC = () => { const signOutUrl = useMemo(() => { const { hostname } = window.location; // If we are developing locally, we need to use the init cluster's public URL - if (hostname === 'localhost') { - return HYDRA_LOGOUT_URL; - } - return `https://${hostname.replace(/^dashboard/, 'sso')}/oauth2/sessions/logout`; + return HYDRA_LOGOUT_URL; }, []); return ( diff --git a/src/services/auth/redux/actions.ts b/src/services/auth/redux/actions.ts index cde2b8e..6d746ca 100644 --- a/src/services/auth/redux/actions.ts +++ b/src/services/auth/redux/actions.ts @@ -1,4 +1,5 @@ -import { createApiAction } from 'src/services/api'; +import axios from 'axios'; +import { createApiAction, createApiCall, performApiCall } from 'src/services/api'; import { SuccessAction } from 'src/services/api/redux/types'; export enum AuthActionTypes { @@ -26,7 +27,7 @@ export const signIn = (params: string) => ); export function signOut() { - return (dispatch: any) => { + return async (dispatch: any) => { dispatch(signOutAction()); }; }