VTEX Login App

repository·main·Indexed 41 days ago

https://github.com/vtex-apps/login

Provides components and logic to handle user authentication and login flows in a VTEX store. Includes the `login` and `login-content` blocks (version 2.x), support for Google One Tap, and query-string parameters for controlling redirects and OAuth flows.

Tokens
2.4K
Snippets
3
Records
8
Agent score
2%

What's inside VTEX Login

  1. Install the Login app

    main

    To use the Login blocks in your theme, add vtex.login version 2.x to your manifest.json dependencies.

    Available blocks:

    • login: Renders the full Login component (Mandatory).
    • login-content: Renders only the login form.
    "dependencies": {
      "vtex.login": "2.x"
    }
  2. Control Login behavior via query-string parameters

    main

    You can customize the behavior of the Login app by appending specific query-string parameters to the URL. This allows you to control redirects, OAuth flows, and the initial state of the login process.

    Supported Parameters

    ParameterDescription
    returnUrlRedirects users to the specified URL after a successful login. Note: This only works for the store domain and must be UTF-8 encoded (e.g., using encodeURIComponent).
    oAuthRedirectBypasses the native login options to redirect directly to an OAuth provider. The provider must be enabled in the component. Values are case-sensitive: Google, Facebook, or the specific name of the chosen provider.
    userEmailProvides the user's email information.
    flowStateSets the default state of the login flow. Use createPass to trigger an email containing a code for creating a new password. Note: Using createPass requires the userEmail parameter to be present in the same URL.
  3. Configure the `login` block

    main

    Add the login block to your store header and configure its properties. Common props include titles, placeholders, and behavior settings.

    Example configuration:

    "login": {
      "props": {
        "emailAndPasswordTitle": "LOG-IN",
        "accessCodeTitle": "Acess Code LOG-IN",
        "emailPlaceholder": "e-mail",
        "passwordPlaceholder": "password",
        "showPasswordVerificationIntoTooltip": true
      }
    }
    "login": {
      "props": {
        "emailAndPasswordTitle": "LOG-IN",
        "accessCodeTitle": "Acess Code LOG-IN",
        "emailPlaceholder": "e-mail",
        "passwordPlaceholder": "password",
        "showPasswordVerificationIntoTooltip": true,
      }
    }
  4. Reference: `login` block props

    main

    The following properties are available for the login block to customize the component's appearance and behavior.

    Prop nameTypeDescriptionDefault
    optionsTitlestringTitle text for login options.undefined
    emailAndPasswordTitlestringText for email and password option.undefined
    accessCodeTitlestringText for access code option.undefined
    emailPlaceholderstringPlaceholder for email input.undefined
    passwordPlaceholderstringPlaceholder for password input.undefined
    acessCodePlaceholderstringPlaceholder for access code input.undefined
    showPasswordVerificationIntoTooltipbooleanShow password format tooltip.true
    showIconProfilebooleanDisplay hpa-profile icon.true
    iconLabelstringTitle text for the Login icon.undefined
    hideIconLabelbooleanHide the Login icon text.false
    labelClasses[string]Login icon classnames.undefined
    providerPasswordButtonLabelstringPassword button label.undefined
    hasIdentifierExtensionbooleanEnable identifier extension configurations.true
    identifierPlaceholderstringPlaceholder for the extension input.undefined
    invalidIdentifierErrorstringError message for invalid identifier.undefined
    mirrorTooltipToRightbooleanOpen tooltip on the right side.false
    logInButtonBehaviorenumpopover (opens popover) or link (redirects to /login).popover
    accountOptionsButtonBehaviorenumpopover (opens popover) or link (redirects to /account).popover
    accountOptionLinks[object]Custom link object to replace default /account behavior.undefined
    termsAndConditionsstringText displayed below login options.undefined
    hasGoogleOneTapbooleanBeta: Enable Google One Tap sign-up/auto sign-in.false
    googleOneTapAlignmentenumBeta: left or right.right
    googleOneTapMarginTopstringBeta: CSS top value for pop-up margin.3rem
    disabledEmailInputsbooleanAllow/disallow user email editing.false
  5. Reference: `login-content` block props

    main

    The login-content block is used when you only want to render the login form. It supports a subset of the login block props.

    Prop nameTypeDescriptionDefault
    isInitialScreenOptionOnlybooleanShow only login options on initial screen.true
    defaultOptionenum0 (access code), 1 (email/password), 2 (corporate).0
    optionsTitlestringTitle text for login options.undefined
    emailAndPasswordTitlestringText for email/password option.undefined
    accessCodeTitlestringText for access code option.undefined
    emailPlaceholderstringPlaceholder for email input.undefined
    passwordPlaceholderstringPlaceholder for password input.undefined
    showPasswordVerificationIntoTooltipbooleanShow password format tooltip.true
    acessCodePlaceholderstringPlaceholder for access code input.undefined
    providerPasswordButtonLabelstringPassword button label.undefined
    hasIdentifierExtensionbooleanEnable identifier extension configurations.true
    identifierPlaceholderstringPlaceholder for the extension input.undefined
    invalidIdentifierErrorstringError message for invalid identifier.undefined
    termsAndConditionsstringText displayed below login options.undefined
    disabledEmailInputsbooleanAllow/disallow user email editing.false
  6. Reference: `accountOptionLinks` object props

    main

    When customizing accountOptionsButtonBehavior to link, use this object to define custom links.

    Prop nameTypeDescription
    labelstringText label for the custom link.
    pathstringCustom link path.
    cssClass[string]Login icon classnames.
  7. Customize Login app styles using CSS handles

    main

    The Login app supports customization via CSS handles. To apply custom styles, follow the standard VTEX IO recipe for Using CSS handles for store customization.

    Below is the complete list of available CSS handles for this app:

    `container`
      `contentInitialScreen`
      `contentFormVisible`
        `profile`
          `label`
        `optionsSticky`
        `optionsList`
        `optionsListItem`
        `optionsListItemContainer`
          `accessCodeOptionBtn`
          `emailPasswordOptionBtn`
          `corporateOptionBtn`
          `facebookOptionBtn`
          `googleOptionBtn`
          `customOAuthOptionBtn`
            `oauthProvider`
            `inputContainer`
              `inputContainerAccessCode`
              `inputContainerPassword`
              `inputContainerEmail`
              `emailVerification`
                `emailForm`
              `emailAndPasswordForm`
              `forgotPasswordForm`
              `formLinkContainer`
                `arrowUp`
                `buttonLink`
                `formError`
                `content`
      `content--emailVerification`
      `content--emailAndPassword`
      `content--codeConfirmation`
      `content--accountOptions`
      `content--recoveryPassword`
        `button`
          `sendButton`
          `buttonSocial`
          `buttonDanger`
          `backButton`
        `accountOptions`
        `codeConfirmation`
        `corporateEmail`
          `formTitle`
          `formSubtitle`
            `box`
        `contentContainer`
        `formFooter`
        `contentForm`
          `contentAlwaysWithOptions`
            `options`
        `tooltipContainer`
          `tooltipContainerTop`
          `tooltipContainerLeft`
        `loginOptionsContainer`
          `termsAndConditions`
          `forgotPasswordLink`
          `dontHaveAccount`
            `eyeIcon`