Open OIDC child session when assuming organization
OIDC login dropped organization_id before the provider redirect, so callbacks with an existing matching root session never created an org child session. Persist organization_id in OIDC state, open the child session on callback, and forward the parameter from the sign-in UI. Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import { useTranslate } from "@probo/i18n";
|
||||
import { Button, Google, Microsoft } from "@probo/ui";
|
||||
import type { ComponentProps } from "react";
|
||||
import { useFragment } from "react-relay";
|
||||
import { useSearchParams } from "react-router";
|
||||
import { graphql } from "relay-runtime";
|
||||
|
||||
import type { OIDCButtonFragment$key } from "#/__generated__/iam/OIDCButtonFragment.graphql";
|
||||
@@ -42,19 +43,24 @@ export function OIDCButton({
|
||||
providerRef: OIDCButtonFragment$key;
|
||||
}) {
|
||||
const { __ } = useTranslate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const safeContinueUrl = useSafeContinueUrl();
|
||||
const provider = useFragment(fragment, providerRef);
|
||||
const Icon = providerIcons[provider.name];
|
||||
const organizationId = searchParams.get("organization-id");
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="secondary"
|
||||
className="w-full h-10"
|
||||
onClick={() => {
|
||||
window.location.href
|
||||
= provider.loginURL
|
||||
+ "?continue="
|
||||
+ encodeURIComponent(safeContinueUrl.toString());
|
||||
const loginURL = new URL(provider.loginURL, window.location.origin);
|
||||
loginURL.searchParams.set("continue", safeContinueUrl.toString());
|
||||
if (organizationId) {
|
||||
loginURL.searchParams.set("organization_id", organizationId);
|
||||
}
|
||||
|
||||
window.location.href = loginURL.toString();
|
||||
}}
|
||||
>
|
||||
<span className="flex items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user