Skip to content

Commit

Permalink
redirect to oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll committed Dec 21, 2023
1 parent f41d4c1 commit 9b22a2f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/lib/utils/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
import { PUBLIC_OIDC_PROVIDER } from '$env/static/public';
import type { ApplicationType } from '../../types';
import { isMobile } from './device';
import { getApplicationDeepLink, getApplicationGotoLink, getApplicationStoreUrl } from './product';
Expand Down Expand Up @@ -50,20 +52,20 @@ export const openRedirectLink = (redirect: string, app: ApplicationType): void =
url.searchParams.append(appStoreUrl.type, base64url(appStoreUrl.url));
}

window.location.href = url.toString();
redirectToOidc(url.toString());
};

/**
* opens the application link.
*
*
* @param {ApplicationType} app - The application to open.
*/
export const attemptToOpenApp = (app: ApplicationType): void => {
if (!browser) return;

const link = getApplicationGotoLink(app);

window.location.href = link;
redirectToOidc(link);

if (isMobile()) {
const appStoreUrl = getApplicationStoreUrl(app);
Expand All @@ -77,3 +79,12 @@ export const attemptToOpenApp = (app: ApplicationType): void => {
}
}
};

/**
* redirects to the oidc provider
*
* @param {string} url - the final url
*/
export const redirectToOidc = (url: string): void => {
goto(`${PUBLIC_OIDC_PROVIDER}?redirectUrl=${url}`);
};

0 comments on commit 9b22a2f

Please sign in to comment.