> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# LoginPassword

> Universal Login の `login-password` 画面をカスタマイズするために使用できる、すべての Hooks とメソッドについて説明します。

`login-password` 画面は、識別子優先の認証フローの第 2 段階で、ユーザーがパスワードを入力する画面です。また、フェデレーションのアイデンティティプロバイダーや別の接続への切り替えにも対応しています。

![ACUL Login Password](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/cdy7uua7fh8z/Em8VqaD4fPUx6FRevD8fh/a9133a19565d5d9ddc1454535a0a7a11/loginpassword.png)

## インポート

各画面には、それぞれ固有の Hooks とメソッドがあります。SDK は各画面で **partial import** と **root import** をサポートしています。

* partial import を使用すると、特定のユースケースに必要なコードだけを含めることができます。
* root import を使用すると、単一のバンドルからすべての画面を読み込めるため、想定されるすべての画面に対応する統一ビルドが必要な場合に便利です。

```jsx Import Example theme={null}
// ルートインポート
import { useLoginPassword } from '@auth0/auth0-acul-react';

// 部分インポート
import {
  useLoginPassword,
  // コンテキストHooks
  useUser,
  useTenant,
  useBranding,
  useClient,
  useOrganization,
  usePrompt,
  useScreen,
  useTransaction,
  useUntrustedData,
  useExperiment,
  // 共通Hooks
  useCurrentScreen,
  useAuth0Themes,
  useErrors,
  // ユーティリティHooks
  useChangeLanguage,
  // メソッド
  login,
  federatedLogin,
  switchConnection,
  switchToOtp,
} from '@auth0/auth0-acul-react/login-password';

function LoginPasswordForm() {
  const { login } = useLoginPassword();
  return (
    <button onClick={() => login({ username: 'user@example.com', password: 'secret' })}>
      Sign In
    </button>
  );
}
```

## Context Hooks

`login-password` 画面で Auth0 のコンテキストデータへの読み取り専用アクセスを提供する、画面スコープのHooksです。`@auth0/auth0-acul-react/login-password` からインポートします。

**useBranding** `() => [BrandingMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/BrandingMembers)`

このHooksは、`login-password` 画面に表示されるロゴ、色、テーマ設定などのブランド設定を提供します。

```jsx Example theme={null}
import { useBranding } from '@auth0/auth0-acul-react/login-password';
function CustomTheme() {
  const branding = useBranding();
}
```

**useClient** `() => [ClientMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/ClientMembers)`

このHooksは、`login-password` 画面の `id`、`name`、`logoUrl` など、クライアント関連の設定を提供します。

```jsx Example theme={null}
import { useClient } from '@auth0/auth0-acul-react/login-password';
function AppInfo() {
  const client = useClient();
}
```

**useExperiment** `() => [ExperimentMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/ExperimentMembers)`

このHooksは、`login-password` 画面で実行中の [Experiment Center](/docs/docs/ja-jp/customize/experiment-center) の experiment を提供します。実行中の experiment がない場合 (または画面が `context_configuration` でオプトインしていない場合) は `null` を返します。

```jsx Example theme={null}
import { useExperiment } from '@auth0/auth0-acul-react/login-password';
function ExperimentBranch() {
  const experiment = useExperiment();
  if (!experiment) return null;
  return experiment.isControl ? <ControlUI /> : <TreatmentUI />;
}
```

**useOrganization** `() => [OrganizationMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/OrganizationMembers)`

このHooksは、ログインが組織スコープの場合に、ユーザーの組織に関する情報を提供します。組織コンテキストが存在しない場合は `null` を返します。

```jsx Example theme={null}
import { useOrganization } from '@auth0/auth0-acul-react/login-password';
function OrgSelector() {
  const organization = useOrganization();
  if (!organization) {
    return <p>組織コンテキストがありません</p>;
  }
}
```

**usePrompt** `() => [PromptMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/PromptMembers)`

このHooksには、認証フロー内の現在の prompt に関するデータが含まれます。

```jsx Example theme={null}
import { usePrompt } from '@auth0/auth0-acul-react/login-password';
function FlowInfo() {
  const prompt = usePrompt();
}
```

**useScreen** `() => [ScreenMembersOnLoginPassword](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/ScreenMembersOnLoginPassword)`

このHooksには、設定やコンテキストを含む `login-password` 画面固有の詳細情報が含まれます。

```jsx Example theme={null}
import { useScreen } from '@auth0/auth0-acul-react/login-password';
function ScreenDebug() {
  const screen = useScreen();
}
```

**useTenant** `() => [TenantMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/TenantMembers)`

このHooksには、`id` や関連するメタデータなど、テナントに関するデータが含まれます。

```jsx Example theme={null}
import { useTenant } from '@auth0/auth0-acul-react/login-password';
function TenantInfo() {
  const tenant = useTenant();
}
```

**useTransaction** `() => [TransactionMembersOnLoginPassword](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/TransactionMembersOnLoginPassword)`

このHooksは、アクティブな接続や現在のフローの状態など、`login-password` 画面に関するトランザクション固有のデータを提供します。

```jsx Example theme={null}
import { useTransaction } from '@auth0/auth0-acul-react/login-password';
function TransactionInfo() {
  const transaction = useTransaction();
}
```

**useUntrustedData** `() => [UntrustedDataMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/UntrustedDataMembers)`

このHooksは、URL パラメーターから事前入力された識別子など、画面に渡される信頼できないデータを処理します。

```jsx Example theme={null}
import { useUntrustedData } from '@auth0/auth0-acul-react/login-password';
function PrefilledForm() {
  const untrustedData = useUntrustedData();
}
```

**useUser** `() => [UserMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/UserMembers)`

このHooksは、`username`、`email`、利用可能な認証方法など、現在のユーザーの詳細を提供します。

```jsx Example theme={null}
import { useUser } from '@auth0/auth0-acul-react/login-password';
function UserProfile() {
  const user = useUser();
}
```

**useLoginPassword** `[LoginPasswordMembers](/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/LoginPasswordMembers)`

このHooksは、`login-password` 画面で利用可能なすべてのメソッドとコンテキストを返します。

## メソッド

**federatedLogin** `Promise\<void\>`

このメソッドは、認証のためにユーザーを [Social](/docs/docs/ja-jp/authenticate/identity-providers/social-identity-providers) または [Enterprise Identity Provider](/docs/docs/ja-jp/authenticate/identity-providers/enterprise-identity-providers) (IdP) にリダイレクトします。

```jsx Example theme={null}
import { useLoginPassword } from '@auth0/auth0-acul-react/login-password';

function SocialButton() {
  const { federatedLogin } = useLoginPassword();
  return (
    <button onClick={() => federatedLogin({ connection: 'google-oauth2' })}>
      Sign In with Google
    </button>
  );
}
```

**メソッドパラメーター**

**パラメーター**

**options**

[FederatedLoginPayloadOptions](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/FederatedLoginPayloadOptions).

**connection** `string` *required*

Social または Enterprise Identity Provider の接続名。

**\[`key`: `string`]** `"string" | "number" | "boolean" | "undefined"`

`ulp-` で始まる追加のカスタムフィールド (例: `'ulp-custom-field'`)。

**login** `Promise\<void\>`

このメソッドは、`login-password` 画面での認証を完了するために、ユーザーの資格情報を送信します。

```jsx Example theme={null}
import { useLoginPassword } from '@auth0/auth0-acul-react/login-password';

function LoginPasswordForm() {
  const { login } = useLoginPassword();
  return (
    <button onClick={() => login({ username: 'user@example.com', password: 'secret' })}>
      サインイン
    </button>
  );
}
```

**メソッドパラメーター**

**パラメーター**

**options**

[LoginPasswordOptions](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/LoginPasswordOptions).

**username** `string` *required*

認証に使用する識別子 (メールアドレス、電話番号、またはユーザー名) 。

**password** `string` *required*

認証に使用するパスワード。

**captcha?** `string`

テナントでボット検出が有効な場合に必要な Captcha 値。

**\[`key`: `string`]** `"string" | "number" | "boolean" | "undefined"`

接頭辞として `ulp-` が付いた追加のカスタムフィールド (例: `'ulp-custom-field'`) 。

**switchConnection** `Promise\<void\>`

このメソッドは、フローをやり直すことなく、別の認証用接続に切り替えます。

```jsx Example theme={null}
import { useLoginPassword } from '@auth0/auth0-acul-react/login-password';

function ConnectionSwitcher() {
  const { switchConnection } = useLoginPassword();
  return (
    <button onClick={() => switchConnection({ connection: 'enterprise-saml' })}>
      SSO を使用
    </button>
  );
}
```

**メソッドパラメーター**

**パラメーター**

**options**

[SwitchConnectionOptionsLoginPassword](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Types/interfaces/SwitchConnectionOptionsLoginPassword).

**connection** `string` *required*

切り替え先の接続名。パスワードレスの場合は 'email' または 'sms' を、パスワードベースの認証の場合は DB 接続名を使用します。

**switchToOtp** `Promise\<void\>`

このメソッドは、このサインインでパスワード入力からワンタイムコードのチャレンジに切り替えます。

オプションを表示する前に `screen.data.showSwitchToOtpButton` を確認してください。これにより、この取引で切り替えが可能かどうかを確認できます。

```jsx Example theme={null}
import { useLoginPassword } from '@auth0/auth0-acul-react/login-password';

function OtpSwitchButton() {
  const { switchToOtp } = useLoginPassword();
  return (
    <button onClick={() => switchToOtp()}>
      代わりにワンタイムコードを使用
    </button>
  );
}
```

## 共通/ユーティリティ Hooks

**[useAuth0Themes](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useAuth0Themes)** `Hooks`

このフックは、ブランディングコンテキストのフラット化された設定を含む現在のテーマオプションを取得します。

**[useChangeLanguage](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useChangeLanguage)** `Hooks`

このフックは、現在の ACUL 画面で表示言語を変更する関数を返します。

**[useCurrentScreen](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useCurrentScreen)** `Hooks`

このフックは、現在の画面のコンテキストと state を取得します。

**[useErrors](/docs/docs/ja-jp/libraries/acul/react-sdk/API-Reference/Hooks/useErrors)** `Hooks`

このフックは、画面上のサーバーエラー、クライアントエラー、開発者エラーを読み取り、管理します。
