ロックのエラーメッセージをカスタマイズする

特定の状況で表示されるエラーメッセージは、languageDictionaryオプションを提供すると、カスタマイズできるようになります。カスタマイズに使用可能なlanguageDictionaryフィールドの全リストは、GitHubリポジトリにあるロック用の英語辞書ファイルに含まれています。以下はカスタマイズされたエラーメッセージの一例です。

codeblockOld.header.login.configureSnippet
// Examples of customized error messages in the languageDictionary option
var options = {
  languageDictionary: {
    error: {
      login: {
        "lock.invalid_email_password": "Custom message about invalid credentials",
        "lock.network": "Custom message indicating a network error and suggesting the user check connection",
        "lock.unauthorized": "Custom message about a failure of permissions",
        "too_many_attempts": "Custom message indicating the user has failed to login too many times."
      },
      signUp: {
        "invalid_password": "Custom message indicating a password was invalid",
        "user_exists": "Custom message indicating that a user already exists"
      }
    }
  }
};

// Initiating our Auth0Lock
var lock = new Auth0Lock(
  '{yourClientId}',
  '{yourDomain}',
  options
);

Was this helpful?

/

ルールのカスタムエラー

ルールやカスタムデータベーススクリプトからのカスタムエラーコードを返している場合には、カスタムエラーを以下のように扱うことができます。

  • アプリケーションのリダイレクトURLで、errorerror_mesageのクエリ文字列パラメーターを読み出す

  • ホストされているページへ、カスタムエラーメッセージと共にユーザーをリダイレクトで戻し、そのメッセージをフラッシュメッセージで表示する

もっと詳しく