Home
Wiki
Home
Wiki
  1. 3. Reusables
  • Back to home
  • 1. Themes
  • Vs Code
    • Getting Started
  • Kitchenware
    • Layout
      • New Layout
      • Legacy Layout
    • Components
      • Announcement
      • Banner Carousel
      • Banner With Products Carousel
      • Blog Category List
      • Blog List
      • Brand List
      • Brands Carousel
      • Breadcrumb
      • Call To Action
      • Cart
      • Categories List
      • Change Password
      • Checkout
      • Cookie Manager
      • Filter list
      • Footer
      • Forgot Password
      • Form
      • Hero Carousel
      • Icon Block
      • Invitation
      • Last Visited Products
      • Layout
      • Login
      • Map
      • Nav Bar
      • Offer
      • Product Attachments
      • Product Attributes
      • Product Documentation
      • Product Expected
      • Product Modal
      • Products Block
      • Products Carousel
      • Product Single
      • Profile
      • Quote
      • Register
      • Related Products
      • Search
      • Stores
      • Subscribe Newsletter
      • Text with Image
      • Top Bar
      • Video
    • Reusables
      • Getting Started
    • Assets
      • Getting Started
    • SDK
      • Products
        • _findProductsByCategory
        • _findProductsByIds
        • _findProductsByTitle
        • _findProductsByFilter
        • _findProductsByCriteria
        • _findProductsAndCalculate
        • _findProductsThenCalculate
        • _getProductAttributeSet
        • _setLastVisited
      • Categories
        • _findCategoryTreeById
        • _findCategoriesByIds
        • _findCategoryByAlias
        • _findCategoryTreeByAlias
        • _getCategoryContent
      • Collections
        • _getCollectionContent
        • _findCollectionsByIds
        • _findCollectionsByIdsThenCalculate
      • Brands
        • _getBrandContent
        • _findBrandsByIds
      • Cart
        • _addToCartMulti
        • _addToCart
        • _setCart
        • _clearCart
        • _setCartListener
        • _removeFromCart
        • _calculateCart
      • Checkout
        • _startCheckout
        • _updateCheckout
        • _completeCheckout
      • Shopping Lists
        • _getShoppingLists
        • _updateShoppingList
        • _createShoppingList
        • _deleteShoppingList
        • _getShoppingListByAlias
      • Navigation
        • _getFooterMenu
        • _getHeaderMenu
      • Users
        • _getUserById
      • Utils
        • _calculateCurrency
        • _getCurrencySymbol
        • _getCulture
        • _subscribeToNewsletter
        • _findUnitsByIds
  • Noir
    • 0. Introduction
    • 1. Structure
      • Overview
      • LayoutA.liquid
      • ComponentsList.liquid
      • Metas.liquid
      • CssVariables.liquid
      • Json.liquid
      • GoogleTagManager.liquid
      • StagingButton.liquid
    • 2. Components
      • Overview
      • Announcement
      • BannerCarousel
      • BlogCategoryList
      • BlogList
      • BrandList
      • Breadcrumb
      • Cart
      • CategoriesList
      • ChangePassword
      • Checkout
      • CookieManager
      • FilterList
      • Footer
      • ForgotPassword
      • Form
      • IconBlock
      • Invitation
      • LastVisitedProducts
      • Login
      • Map
      • NavBar
      • ProductAttachments
      • ProductAttributes
      • ProductComparison
      • ProductDocumentation
      • ProductMixList
      • ProductsBlock
      • ProductsCarousel
      • ProductSingle
      • Profile
      • Register
      • RelatedProducts
      • SingleBlog
      • Stores
      • TextWithImage
      • ThankYouPage
      • TopBar
      • Wishlist
    • 3. Reusables
      • Overview
      • Addresses
      • BillingRetail
      • AddressForm
      • AnnouncementModal
      • BackToTop
      • Company
      • General
      • Login
      • LoginModal
      • Orders
      • Payment
      • ProductAttachments
      • ProductAttributes
      • ProductComparisonButton
      • ProductComparisonFloatingButton
      • ProductGridItem
      • ProductListItem
      • ShoppingListsButton
      • ProductModal
      • ProfileInfo
      • PromptModal
      • Register
      • Shipping
      • ShoppingLists
      • ShoppingListsNavbar
      • Toast
      • Users
      • VariantContent
      • WishlistButton
      • Services
    • 4. Assets
      • Fonts
      • Images
      • Templates
      • Javascript
        • Overview
        • theme.js
      • Css / Scss
        • Overview
        • ThemeClasses
    • 5. SDK
      • Overview
      • LiquidGlobals
      • ServicesSDK
  1. 3. Reusables

Login

Purpose#

Login is the reusable that renders and submits the login form (email + password).
It’s used both:
As the main form on the /login page (via the Login component).
Inside the LoginModal reusable (tabs: login/register).
The reusable validates fields client-side, calls the login API, shows toast messages for success/errors, and then redirects/reloads depending on context.

Where it's rendered#

Login page#

In Components/Login/Default.liquid:
{% render 'Reusables\\Login\\Default', uniquekey: uniquekey %}

Login modal#

In Reusables/LoginModal/Default.liquid:
{% render 'Reusables\\Login\\Default', uniquekey: uniquekey %}

Inputs (Liquid render parameters)#

Login is rendered with a single parameter.

Model shape (storefront example)#

Not applicable (this reusable doesn’t receive a platform model object).
It receives only uniquekey from the caller (generated in Liquid) to create unique input ids/names.

Required fields#

uniquekey (string)
Used to generate deterministic DOM ids/names:
login-email-{{ uniquekey }}
login-password-{{ uniquekey }}
field names are also suffixed with the same value.

Optional fields#

None.

Template behavior (Liquid + Alpine)#

Source: Reusables/Login/Default.liquid.
Root form uses Alpine data:
x-data="loginreusabledefault"
Submission is handled by @submit.prevent, passing translations (toast messages):
@submit.prevent="checkForm('{{ uniquekey }}', ...toast messages...)"
Password visibility is toggled via toggleVisibility($event).

Data contract (JS runtime)#

The Alpine object is loginreusabledefault from Reusables/Login/Default.js.
State:
fields (array of input elements)
errors (object map: fieldName -> errorType)
isSending (boolean)

JavaScript#

Source: Reusables/Login/Default.js.

init()#

Collects fields within the form (skipping .skipped, disabled, and submit buttons).
Adds blur listeners to run validateField.
Listens for a global event:
clear-login-modal-forms
When received, it clears the form and optionally clears toasts (unless detail.preserveToasts is true).

validateField(field)#

Adds errors:
required
invalidEmail
Updates CSS classes valid/invalid and optional state icons.

toggleVisibility(event)#

Finds the associated password input by converting checkbox id:
toggle-login-password-<uniquekey> -> login-password-<uniquekey>
Toggles input type between password and text.
Switches icon classes (ic-eye-off / ic-preview).

updateFormValidity()#

Returns true if every field is valid (no errors + required fields filled).

clearForm()#

Clears values and resets classes/icons.
Clears errors.

checkForm(uniquekey, successMessage, errorMessage, errorMessageCredentials, errorMessageLocked)#

Main form flow:
1.
Clears all toasts.
2.
Validates fields; stops if invalid.
3.
Calls login service:
servicesreusabledefault.accountLogin({ Email, Password })
4.
Error handling:
If response.status == 409 → shows “locked” toast.
Otherwise → resets field visuals and shows “invalid credentials” toast.
5.
On success:
Clears form.
Shows success toast.
Redirect logic:
If query starts with ?redirect=http(s):// → redirects to that target.
Else if on /login → redirects to / after a short delay.
Else if $store.loginModal.goToCheckoutPage → redirects to /checkout.
Else → reloads the current page.

Global Alpine stores#

Used by Login JS:
$store.toast
removeAll() and add(...) for feedback.
$store.loginModal
Reads and updates goToCheckoutPage to decide whether to redirect to checkout.

Services / API calls#

servicesreusabledefault.accountLogin({ Email, Password })

Dependencies#

Reusables/Login/Default.liquid
Reusables/Login/Default.js
Reusables/Login/Default.json (translations)
Components/Login/Default.liquid (render on login page)
Reusables/LoginModal/Default.liquid (render in modal)
$store.toast and $store.loginModal in Assets/js/theme.js
servicesreusabledefault.accountLogin

Notes#

The reusable expects the generated uniquekey to be unique per instance, otherwise the document.querySelector('#login-email-' + uniquekey) selectors may target the wrong input.
For security, the redirect logic only allows absolute redirects when they come from the ?redirect=http(s)://... query string.

Examples#

Login page:
{% render 'Reusables\\Login\\Default', uniquekey: uniquekey %}
Login modal:
{% render 'Reusables\\Login\\Default', uniquekey: uniquekey %}
Modified at 2026-04-14 13:18:56
Previous
General
Next
LoginModal
Built with