Authentication & Delivery
Customer login/registration, the login modal helper, and the delivery-setup overlay.
Authentication
storefront.auth exposes customer authentication methods. All callbacks receive (code, body) — same raw shape as the underlying API response.
| Method | Description |
|---|---|
login(email, password, cb) |
Log in with email and password. |
createAccount(body, cb) |
Register a new customer. body: { email, password, name, … }. |
checkExists(email, cb) |
Check whether an account exists for the given email. |
forgotPassword(email, cb) |
Send a password-reset email. |
validateOTPCode(email, otp, otpMode, activationToken, password, customPhone, cb) |
Validate a one-time password. otpMode: 'otp_email' or 'otp_sms'. |
resendOTPCode(email, otpMode, customPhone, cb) |
Resend an OTP code. |
skipOTPValidation(cb) |
Skip OTP validation (if allowed by shop settings). |
oauthLogin(provider) |
Initiate an OAuth flow. provider: 'google' or 'github'. Submits a form; no callback. |
isLoggedIn(cb) |
Check session state. Calls cb(isLoggedIn, userData) — userData is the /user.json body when logged in. |
storefront.auth.isLoggedIn(function(loggedIn, user) {
if (loggedIn) console.log('Hello', user.name)
})
storefront.auth.login('customer@example.com', 'secret', function(code, body) {
if (code === 200) console.log('Logged in')
})
openLogin()
openLogin(storefront, opts) — exported from bolder-storefront — imperatively opens the login/signup modal. It mounts the AuthDelivery component into a managed overlay on the first call and reuses it on subsequent calls.
import { createStorefront, openLogin } from 'bolder-storefront'
createStorefront({ shop: 'acme' }).then(function(storefront) {
document.querySelector('#login-btn').addEventListener('click', function() {
openLogin(storefront, {
onLoginComplete: function() {
console.log('User is now logged in')
}
})
})
})
opts is forwarded to the component’s showLogin() method. The most useful option is onLoginComplete — a callback fired after a successful login or registration.
Delivery Setup
storefront.delivery provides access to shipping and delivery data (countries, regions, methods). It is used internally by the DeliverySetup component and by openDeliverySetup().
openDeliverySetup(storefront, opts) and closeDeliverySetup() — both exported from bolder-storefront — open and close a managed delivery-setup overlay. The overlay lazily mounts DeliverySetupV2 on first call.
import { createStorefront, openDeliverySetup, closeDeliverySetup } from 'bolder-storefront'
createStorefront({ shop: 'acme' }).then(function(storefront) {
document.querySelector('#change-delivery').addEventListener('click', function() {
openDeliverySetup(storefront, {
allowPickup: true,
allowShipping: true,
onComplete: function() {
console.log('Delivery setup completed')
closeDeliverySetup()
}
})
})
})
| Option | Type | Description |
|---|---|---|
allowPickup |
boolean |
Show in-store pickup options. |
allowShipping |
boolean |
Show shipping address options. |
onComplete |
function |
Called when the customer confirms their delivery choice. |