Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions packages/react-ui/src/app/lib/frontegg-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,38 @@ export const additionalFronteggParams = {
prompt: 'select_account',
};

export function initializeFrontegg(url: string, tenant?: string): FronteggApp {
const tenantResolver = tenant ? () => ({ tenant }) : undefined;
let fronteggApp: FronteggApp | null = null;

type Options = {
url: string;
clientId?: string;
tenant?: string;
};

return initialize({
export function initializeFrontegg({
url,
clientId,
tenant,
}: Options): FronteggApp {
if (fronteggApp) {
return fronteggApp;
}
Comment thread
alexandrudanpop marked this conversation as resolved.
const tenantResolver = tenant ? () => ({ tenant }) : undefined;
const options = {
contextOptions: {
baseUrl: url,
clientId,
tenantResolver,
},
authOptions: {
keepSessionAlive: true,
},
hostedLoginBox: true,
});
};
fronteggApp = initialize(options);
return fronteggApp;
}

export function getFronteggApp(): FronteggApp | null {
return fronteggApp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const CloudConnectionPage = () => {
return;
}

const app = initializeFrontegg(FRONTEGG_URL as string);
const app = initializeFrontegg({ url: FRONTEGG_URL as string });

app.ready(() => {
app.store.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CloudLogoutPage = () => {
return;
}

const app = initializeFrontegg(FRONTEGG_URL as string);
const app = initializeFrontegg({ url: FRONTEGG_URL as string });

Cookies.remove('cloud-token');
Cookies.remove('cloud-refresh-token');
Expand Down
Loading