mfa-otp-challenge 画面では、MFA の確認を完了するために、認証アプリで生成されたワンタイムパスワードを入力するようユーザーに求めます。
各画面には、それぞれ固有のフックとメソッドのセットがあります。SDK は、各画面で部分インポートとルートインポートをサポートしています。
- 部分インポートを使用すると、特定のユースケースに必要なコードだけを取り込めます。
- ルートインポートを使用すると、単一のバンドルからすべての画面を読み込めます。これは、想定されるすべての画面を 1 つの統一ビルドで処理したい場合に便利です。
// ルートインポート
import { useMfaOtpChallenge } from '@auth0/auth0-acul-react';
// 部分インポート
import {
useMfaOtpChallenge,
// コンテキストフック
useUser,
useTenant,
useBranding,
useClient,
useOrganization,
usePrompt,
useScreen,
useTransaction,
useUntrustedData,
// 共通フック
useCurrentScreen,
useAuth0Themes,
useErrors,
// ユーティリティフック
useChangeLanguage,
// メソッド
continueMethod,
tryAnotherMethod,
} from "@auth0/auth0-acul-react/mfa-otp-challenge";
function MfaOtpChallengeScreen() {
const { continueMethod } = useMfaOtpChallenge();
return (
<button onClick={() => continueMethod({ code: '123456' })}>
Verify Code
</button>
);
}
mfa-otp-challenge 画面で Auth0 のコンテキストデータへの読み取り専用アクセスを提供する、画面スコープのフックです。@auth0/auth0-acul-react/mfa-otp-challenge からインポートします。
このフックは、mfa-otp-challenge 画面に表示されるロゴ、色、テーマ設定などのブランディング設定を提供します。import { useBranding } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function CustomTheme() {
const branding = useBranding();
}
このフックは、mfa-otp-challenge 画面の id、name、logoUrl などのクライアント関連設定を提供します。import { useClient } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function AppInfo() {
const client = useClient();
}
このフックは、MFA フローが組織スコープである場合に、ユーザーの組織に関する情報を提供します。組織コンテキストが存在しない場合は null を返します。import { useOrganization } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function OrgSelector() {
const organization = useOrganization();
if (!organization) {
return <p>No organization context</p>;
}
}
このフックは、認証フロー内の現在のプロンプトに関するデータを提供します。import { usePrompt } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function FlowInfo() {
const prompt = usePrompt();
}
このフックは、設定やコンテキストなど、mfa-otp-challenge 画面固有の詳細を提供します。import { useScreen } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function ScreenDebug() {
const screen = useScreen();
}
このフックは、id や関連メタデータなど、テナントに関するデータを提供します。import { useTenant } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function TenantInfo() {
const tenant = useTenant();
}
このフックは、現在の MFA フローの状態など、mfa-otp-challenge 画面のトランザクション固有データを提供します。import { useTransaction } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function TransactionInfo() {
const transaction = useTransaction();
}
このフックは、URL パラメーターから事前入力された値など、画面に渡される信頼されていないデータを扱います。import { useUntrustedData } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function PrefilledForm() {
const untrustedData = useUntrustedData();
}
このフックは、現在のユーザーの詳細 (username、email、利用可能な認証方法など) を返します。import { useUser } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function UserProfile() {
const user = useUser();
}
このフックは、mfa-otp-challenge 画面で使用できるすべてのメソッドとコンテキストを返します。
このメソッドは、ユーザーが入力したワンタイムパスワードを送信して、OTP チャレンジを完了します。import { useMfaOtpChallenge } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function OtpChallengeForm() {
const { continueMethod } = useMfaOtpChallenge();
return (
<button onClick={() => continueMethod({ code: '123456', rememberDevice: true })}>
Verify
</button>
);
}
メソッド パラメーター
このメソッドは MFA の方法選択画面に移動し、ユーザーが別の認証要素を選択できるようにします。import { useMfaOtpChallenge } from '@auth0/auth0-acul-react/mfa-otp-challenge';
function TryAnotherMethodButton() {
const { tryAnotherMethod } = useMfaOtpChallenge();
return (
<button onClick={() => tryAnotherMethod()}>
Try Another Method
</button>
);
}
このフックは、ブランディングコンテキストから、フラット化された設定を含む現在のテーマオプションを取得します。
このフックは、現在の ACUL 画面の表示言語を変更する関数を返します。
このフックは、現在の画面のコンテキストと状態を取得します。
このフックは、画面上のサーバー、クライアント、開発者のエラーを読み取って管理します。