Overview
The Customer module provides:- Customer Accounts - Customer registration and profiles
- Authentication - Login, logout, and session management
- Address Management - Customer shipping and billing addresses
- Password Management - Password reset and change
- Customer Groups - Segment customers into groups
- Order History - Customer order tracking
Module Structure
GraphQL Types
Customer Type
Customer Address Type
Authentication
Customer Registration
Customers can create accounts through:- Registration form on the storefront
- Checkout process (optional account creation)
- Admin panel (by administrators)
Customer Login
Authentication uses session-based login:Session Management
Customer sessions are:- Stored in the database (
sessiontable) - Managed by
express-session - Linked to the customer account
- Persistent across page reloads
Password Security
Passwords are secured using:- bcrypt hashing algorithm
- Salt rounds: 10 (configurable)
- Minimum requirements: Enforced in validation
Customer Accounts
Customer Profile
Customers can manage their profile information:- Email address
- First and last name
- Phone number
- Default addresses
- Password
Account Dashboard
The customer account dashboard provides:- Order history
- Address book
- Account information
- Password change
Address Management
Adding Addresses
Customers can save multiple addresses:Default Addresses
Customers can set:- Default shipping address - Used for new orders
- Default billing address - Used for payments
Address Validation
Address validation includes:- Required fields check
- Country/province validation
- Postal code format (basic)
- Phone number format
Password Management
Password Reset
The password reset flow:Change Password
Logged-in customers can change their password:Customer Groups
Customer groups allow segmentation:- General - Default customer group
- Wholesale - Wholesale customers
- VIP - Premium customers
- Custom groups - Create custom segments
- Pricing rules
- Promotions
- Access control
Database Schema
The Customer module defines:customer- Customer account datacustomer_address- Customer addressescustomer_group- Customer segmentation
GraphQL Queries
Get Current Customer
Get Customer (Admin)
Customer Services
The Customer module exports these services:Admin Customer Management
Administrators can:- View all customers
- Create customer accounts
- Edit customer information
- Reset customer passwords
- Disable customer accounts
- View customer order history
- Manage customer groups
Best Practices
Email Verification: Consider implementing email verification for new customer accounts to prevent fake registrations.
Privacy & Security
Data Protection
- Passwords are hashed with bcrypt
- Sensitive data is encrypted
- Session tokens are secure and http-only
- GDPR compliance considerations
Account Security
- Failed login attempt tracking
- Session timeout configuration
- Secure password reset process
- Email confirmation for sensitive changes
API Endpoints
Key customer API endpoints:POST /api/customer/register- Customer registrationPOST /api/customer/login- Customer loginPOST /api/customer/logout- Customer logoutGET /api/customer/me- Get current customerPATCH /api/customer/:id- Update customerPOST /api/customer/addresses- Add addressPATCH /api/customer/addresses/:id- Update addressDELETE /api/customer/addresses/:id- Delete addressPOST /api/customer/forgotPassword- Request password resetPOST /api/customer/resetPassword- Reset passwordPOST /api/customer/changePassword- Change password
Related Documentation
Customer Services API
Learn about the Customer services API
Authentication
Understanding authentication middleware
Orders Module
Customer order management
GraphQL Queries
Customer GraphQL queries