File tree Expand file tree Collapse file tree
packages/react-ui/src/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,17 +5,38 @@ export const additionalFronteggParams = {
55 prompt : 'select_account' ,
66} ;
77
8- export function initializeFrontegg ( url : string , tenant ?: string ) : FronteggApp {
9- const tenantResolver = tenant ? ( ) => ( { tenant } ) : undefined ;
8+ let fronteggApp : FronteggApp | null = null ;
9+
10+ type Options = {
11+ url : string ;
12+ clientId ?: string ;
13+ tenant ?: string ;
14+ } ;
1015
11- return initialize ( {
16+ export function initializeFrontegg ( {
17+ url,
18+ clientId,
19+ tenant,
20+ } : Options ) : FronteggApp {
21+ if ( fronteggApp ) {
22+ return fronteggApp ;
23+ }
24+ const tenantResolver = tenant ? ( ) => ( { tenant } ) : undefined ;
25+ const options = {
1226 contextOptions : {
1327 baseUrl : url ,
28+ clientId,
1429 tenantResolver,
1530 } ,
1631 authOptions : {
1732 keepSessionAlive : true ,
1833 } ,
1934 hostedLoginBox : true ,
20- } ) ;
35+ } ;
36+ fronteggApp = initialize ( options ) ;
37+ return fronteggApp ;
38+ }
39+
40+ export function getFronteggApp ( ) : FronteggApp | null {
41+ return fronteggApp ;
2142}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ const CloudConnectionPage = () => {
4343 return ;
4444 }
4545
46- const app = initializeFrontegg ( FRONTEGG_URL as string ) ;
46+ const app = initializeFrontegg ( { url : FRONTEGG_URL as string } ) ;
4747
4848 app . ready ( ( ) => {
4949 app . store . subscribe ( ( ) => {
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ const CloudLogoutPage = () => {
3737 return ;
3838 }
3939
40- const app = initializeFrontegg ( FRONTEGG_URL as string ) ;
40+ const app = initializeFrontegg ( { url : FRONTEGG_URL as string } ) ;
4141
4242 Cookies . remove ( 'cloud-token' ) ;
4343 Cookies . remove ( 'cloud-refresh-token' ) ;
You can’t perform that action at this time.
0 commit comments