Skip to content

Commit

Permalink
feat(AuthLinker): use bl-web Auth Gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianAndersen committed Aug 12, 2024
1 parent 4524726 commit 0ba9e95
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/components/AuthLinker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ export function executeReturnRedirect(
searchParams: ReadonlyURLSearchParams,
router: AppRouterInstance,
) {
let target = "";

const caller = searchParams.get("caller");
const baseUrl =
caller === "bl-web"
? BL_CONFIG.blWeb.basePath
: caller === "bl-admin"
? BL_CONFIG.blAdmin.basePath
: "/";
const path =
caller == "bl-admin" ? "auth/gateway" : searchParams.get("redirect") ?? "";
router.replace(attachTokensToHref(baseUrl + path));
const redirect = searchParams.get("redirect");
if (caller === "bl-web") {
target = `${BL_CONFIG.blWeb.basePath}auth/gateway?redirect=${redirect}`;
} else if (caller === "bl-admin") {
target = `${BL_CONFIG.blAdmin.basePath}auth/gateway`;
} else {
target = "/";
}
router.replace(attachTokensToHref(target));
}

export default function AuthLinker({ children }: { children: ReactNode }) {
Expand Down

0 comments on commit 0ba9e95

Please sign in to comment.