File tree Expand file tree Collapse file tree
packages/react-ui/src/app
features/authentication/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { FlagsMap } from '@/app/lib/flags-api' ;
2+
3+ export const getFederatedUrlBasedOnFlags = ( flags : FlagsMap ) =>
4+ flags . FEDERATED_LOGIN_ENABLED
5+ ? ( flags . FRONTEGG_URL as string | undefined )
6+ : undefined ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { jwtDecode } from 'jwt-decode';
44import { Suspense , useEffect } from 'react' ;
55import { Navigate , useLocation , useNavigate } from 'react-router-dom' ;
66
7+ import { getFederatedUrlBasedOnFlags } from '@/app/common/auth/lib/utils' ;
78import { flagsHooks } from '@/app/common/hooks/flags-hooks' ;
89import { platformHooks } from '@/app/common/hooks/platform-hooks' ;
910import { projectHooks } from '@/app/common/hooks/project-hooks' ;
@@ -61,7 +62,7 @@ export const AllowOnlyLoggedInUserOnlyGuard = ({
6162 await authenticationSession . logOut ( {
6263 userInitiated : false ,
6364 navigate,
64- federatedLoginUrl : flags ?. FRONTEGG_URL as string | undefined ,
65+ federatedLoginUrl : getFederatedUrlBasedOnFlags ( flags ) ,
6566 } ) ;
6667 } catch ( e ) {
6768 if ( isMounted ) {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { t } from 'i18next';
1515import { SubmitHandler , useForm } from 'react-hook-form' ;
1616import { Link , useNavigate } from 'react-router-dom' ;
1717
18+ import { getFederatedUrlBasedOnFlags } from '@/app/common/auth/lib/utils' ;
1819import { flagsHooks } from '@/app/common/hooks/flags-hooks' ;
1920import { HttpError , api } from '@/app/lib/api' ;
2021import { authenticationApi } from '@/app/lib/authentication-api' ;
@@ -26,7 +27,7 @@ import {
2627 SignInRequest ,
2728 emailRegex ,
2829} from '@openops/shared' ;
29- import { useEffectOnce } from 'react-use ' ;
30+ import { useEffect } from 'react' ;
3031import { navigationUtil } from '../../../lib/navigation-util' ;
3132
3233const SignInSchema = Type . Object ( {
@@ -52,11 +53,17 @@ const SignInForm: React.FC = () => {
5253 mode : 'onChange' ,
5354 } ) ;
5455
55- useEffectOnce ( ( ) => {
56+ const { data : flags } = flagsHooks . useFlags ( ) ;
57+
58+ useEffect ( ( ) => {
59+ if ( ! flags ) {
60+ return ;
61+ }
5662 authenticationSession . logOut ( {
5763 userInitiated : false ,
64+ federatedLoginUrl : getFederatedUrlBasedOnFlags ( flags ) ,
5865 } ) ;
59- } ) ;
66+ } , [ flags ] ) ;
6067
6168 const { data : edition } = flagsHooks . useFlag ( FlagId . EDITION ) ;
6269 const { data : showSignUpLink } = flagsHooks . useFlag ( FlagId . SHOW_SIGN_UP_LINK ) ;
Original file line number Diff line number Diff line change 1+ import { getFederatedUrlBasedOnFlags } from '@/app/common/auth/lib/utils' ;
12import { API_URL , isUrlRelative } from '@/app/lib/api' ;
23import { authenticationSession } from '@/app/lib/authentication-session' ;
34import axios , { AxiosError , HttpStatusCode } from 'axios' ;
@@ -60,12 +61,13 @@ axios.interceptors.response.use(
6061 if ( url !== OPENOPS_CLOUD_USER_INFO_API_URL && ! isSignInRoute ) {
6162 console . warn ( 'JWT expired logging out' ) ;
6263
63- const flags = queryClient . getQueryData < FlagsMap > ( [ QueryKeys . flags ] ) ;
64+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
65+ const flags = queryClient . getQueryData < FlagsMap > ( [ QueryKeys . flags ] ) ! ;
6466 authenticationSession . logOut ( {
6567 userInitiated : false ,
66- federatedLoginUrl : flags ?. FRONTEGG_URL as string | undefined ,
68+ federatedLoginUrl : getFederatedUrlBasedOnFlags ( flags ) ,
6769 } ) ;
68- if ( ! flags ?. FRONTEGG_URL ) {
70+ if ( ! flags ?. FEDERATED_LOGIN_ENABLED ) {
6971 window . location . reload ( ) ;
7072 }
7173 }
You can’t perform that action at this time.
0 commit comments