organization-picker 画面は、ユーザーがログインする組織を選択する必要がある場合に表示されます。ユーザーは組織を選択することも、この選択手順をスキップすることもできます。
各画面には、それぞれ専用のフックとメソッドが用意されています。SDK は各画面で部分インポートとルートインポートをサポートしています。
- 部分インポートを使用すると、特定のユースケースに必要なコードだけを含めることができます。
- ルートインポートを使用すると、単一のバンドルからすべての画面を読み込めます。これは、1 つの統一されたビルドですべての可能な画面に対応したい場合に便利です。
// ルートインポート
import { useOrganizationPicker } from '@auth0/auth0-acul-react';
// 部分インポート
import {
useOrganizationPicker,
// コンテキストフック
useUser,
useTenant,
useBranding,
useClient,
useOrganization,
usePrompt,
useScreen,
useTransaction,
useUntrustedData,
// 共通フック
useCurrentScreen,
useAuth0Themes,
useErrors,
// ユーティリティフック
useChangeLanguage,
// メソッド
selectOrganization,
skipOrganizationSelection,
} from '@auth0/auth0-acul-react/organization-picker';
function OrganizationPickerScreen() {
const { selectOrganization } = useOrganizationPicker();
return (
<button onClick={() => selectOrganization({ organization: 'my-org', state: 'abc123' })}>Select</button>
);
}
organization-picker 画面で Auth0 のコンテキストデータへの読み取り専用アクセスを提供する、画面スコープのフックです。@auth0/auth0-acul-react/organization-picker からインポートします。
このフックは、organization-picker 画面に表示されるロゴ、色、テーマ設定などのブランディング設定を提供します。import { useBranding } from '@auth0/auth0-acul-react/organization-picker';
function CustomTheme() {
const branding = useBranding();
}
このフックは、organization-picker 画面の id、name、logoUrl など、クライアント関連の設定を提供します。import { useClient } from '@auth0/auth0-acul-react/organization-picker';
function AppInfo() {
const client = useClient();
}
このフックは、organization-picker 画面におけるユーザーの組織コンテキストに関する情報を提供します。組織コンテキストが存在しない場合は null を返します。import { useOrganization } from '@auth0/auth0-acul-react/organization-picker';
function OrgSelector() {
const organization = useOrganization();
if (!organization) {
return <p>No Organization context</p>;
}
}
このフックには、認証フローの現在のプロンプトに関するデータが含まれます。import { usePrompt } from '@auth0/auth0-acul-react/organization-picker';
function FlowInfo() {
const prompt = usePrompt();
}
このフックには、設定やコンテキストなど、organization-picker 画面固有の詳細が含まれます。import { useScreen } from '@auth0/auth0-acul-react/organization-picker';
function ScreenDebug() {
const screen = useScreen();
}
このフックには、id や関連するメタデータなど、テナントに関するデータが含まれます。import { useTenant } from '@auth0/auth0-acul-react/organization-picker';
function TenantInfo() {
const tenant = useTenant();
}
このフックは、アクティブな接続や現在のフロー状態など、organization-picker 画面のトランザクション固有のデータを提供します。import { useTransaction } from '@auth0/auth0-acul-react/organization-picker';
function TransactionInfo() {
const transaction = useTransaction();
}
このフックは、URL のクエリ文字列から事前入力されたパラメーターなど、画面に渡される信頼できないデータを扱います。import { useUntrustedData } from '@auth0/auth0-acul-react/organization-picker';
function PrefilledForm() {
const untrustedData = useUntrustedData();
}
このフックは、現在のユーザーに関する情報 (username、email、利用可能な認証方法など) を提供します。import { useUser } from '@auth0/auth0-acul-react/organization-picker';
function UserProfile() {
const user = useUser();
}
このフックは、organization-picker 画面で使用できるすべてのメソッドとコンテキストを返します。
このメソッドは、ユーザーが選択した組織を送信し、認証フローを次のステップに進めます。import { useOrganizationPicker } from '@auth0/auth0-acul-react/organization-picker';
function SelectButton() {
const { selectOrganization } = useOrganizationPicker();
return (
<button onClick={() => selectOrganization({ organization: 'my-org', state: 'abc123' })}>
Select Organization
</button>
);
}
メソッド パラメーター
skipOrganizationSelection
このメソッドを使用すると、ユーザーは組織の選択ステップをスキップし、組織を選択せずに認証フローを次のステップに進めることができます。import { useOrganizationPicker } from '@auth0/auth0-acul-react/organization-picker';
function SkipButton() {
const { skipOrganizationSelection } = useOrganizationPicker();
return (
<button onClick={() => skipOrganizationSelection()}>
Skip
</button>
);
}
このフックは、ブランディングコンテキストのフラット化された設定を含む現在のテーマオプションを取得します。
このフックは、現在の ACUL 画面の表示言語を変更する関数を返します。
このフックは、現在の画面のコンテキストと state を取得します。
このフックは、画面上のサーバー、クライアント、開発者のエラーを読み取り、管理します。