Skip to content

Commit 869655c

Browse files
Add client id to frontegg app (#1688)
<!-- Ensure the title clearly reflects what was changed. Provide a clear and concise description of the changes made. The PR should only contain the changes related to the issue, and no other unrelated changes. --> Fixes OPS-3151 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 73f2b19 commit 869655c

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

packages/react-ui/src/app/lib/frontegg-setup.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

packages/react-ui/src/app/routes/cloud-connection/cloud-connection-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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(() => {

packages/react-ui/src/app/routes/cloud-connection/cloud-logout-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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');

0 commit comments

Comments
 (0)