Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WCA Auth Engine

Tests License: GPL v2+ WordPress: >= 6.0 WooCommerce: >= 7.0 PHP: >= 8.1

WCA Auth Engine is a high-performance, decoupled authentication and registration system built specifically for WooCommerce and WordPress (Single-Site & Multisite).

It replaces native WordPress/WooCommerce login and registration forms with an optimized, REST-API-driven pipeline featuring pre-database registration gating, multi-identifier authentication (Email, Username, or Phone), dual OTP verification (Native Email + TextMagic SMS), and WooCommerce checkout field locking.


πŸš€ Core Architectural Features

1. Pre-Database Registration Pipeline (WCA_Registration_Pipeline)

Standard WordPress registration immediately inserts unverified users into wp_users. WCA Auth Engine uses a decoupled 3-Phase Transient Pipeline:

  • Phase 1 (Initiate): Validates payload, hashes passwords immediately, and stores session data inside temporary encrypted transients. Zero database user rows are created.
  • Phase 2 (Verify): User completes verification via Email magic link/token or SMS OTP code. Transient flags (email_verified, sms_verified) are updated.
  • Phase 3 (Complete): Once verified, wp_create_user() is called, user meta (billing_phone, billing_phone_verified, billing_email_verified) is attached, authentication cookies are set, and transients are purged.

2. Multi-Identifier Auth (WCA_Identifier_Resolver)

Users can log in or initiate passwordless verification using any valid identifier:

  • Email Address (user@example.com)
  • Username (john_doe)
  • Phone Number (+1234567890)

3. Dual OTP Engine (WCA_OTP_Dispatcher)

  • Native Email Verification: HTML email templates rendered via WCA_Template_Engine and sent through native wp_mail().
  • SMS Verification: Built-in TextMagic API integration (WCA_TextMagic_Client) with customizable SMS message templates.
  • Flexible Channels: Users can choose between SMS and Email OTP or switch channels seamlessly during verification.

4. WooCommerce Checkout Integration (WCA_Checkout_Guard & WCA_Checkout_Field_Locker)

  • Field Locking: Locks billing_phone and billing_email on the WooCommerce Checkout page to match the authenticated user's verified contact details, preventing spoofed checkouts.
  • Checkout Enforcement: Enforces valid account status and phone/email verification prior to order placement.

5. Account Profile & Reverification Guard (WCA_Profile_Update_Manager)

  • Intercepts WooCommerce "Edit Account" and billing profile fields.
  • Updating phone numbers or email addresses automatically flags the account for OTP re-verification before saving changes to user meta.

6. Decoupled Alpine.js Frontend Modals

Lightweight, responsive AJAX/REST API frontend modals (frontend/templates/) powered by Alpine.js:

  • Modal Register (modal-register.php)
  • Modal Login (modal-login.php)
  • Modal OTP Verification (modal-otp-verify.php)
  • Modal Password Reset (modal-forgot-password.php)
  • Modal Profile Update (modal-profile-update.php)
  • Modal Add Phone (modal-add-phone.php for legacy users)

7. User Table Tools & Admin Panel (WCA_User_Table_Columns & WCA_Admin_User_Tools)

  • Adds Phone, Phone Status, and Email Status columns directly to WordPress User tables (wp-admin/users.php).
  • Provides network-wide options management for WordPress Multisite networks (WCA_Network_Admin).
  • Built-in log viewer (WCA_Log_Viewer) and email test controller (WCA_Email_Test_Controller).

πŸ› οΈ Codebase Structure

wca-auth-engine/
β”œβ”€β”€ wca-auth-engine.php             # Main plugin bootstrap & hook registration
β”œβ”€β”€ uninstall.php                   # Cleanup script on plugin deletion
β”œβ”€β”€ email-templates/                # Responsive HTML email templates
β”‚   β”œβ”€β”€ login-otp.html
β”‚   β”œβ”€β”€ password-reset.html
β”‚   β”œβ”€β”€ profile-update-verify.html
β”‚   └── registration-verify.html
β”œβ”€β”€ frontend/                       # Decoupled frontend assets & templates
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── wca-auth.css            # Styles for authentication modals
β”‚   β”œβ”€β”€ js/
β”‚   β”‚   β”œβ”€β”€ wca-auth-app.js         # Alpine.js application controller
β”‚   β”‚   β”œβ”€β”€ wca-otp-input.js        # Auto-focusing OTP input handler
β”‚   β”‚   └── wca-admin-settings.js   # Admin dashboard JS
β”‚   └── templates/                  # PHP Modal view templates
β”‚       β”œβ”€β”€ modal-add-phone.php
β”‚       β”œβ”€β”€ modal-forgot-password.php
β”‚       β”œβ”€β”€ modal-login.php
β”‚       β”œβ”€β”€ modal-otp-verify.php
β”‚       β”œβ”€β”€ modal-profile-update.php
β”‚       β”œβ”€β”€ modal-register.php
β”‚       └── modal-reverify-email.php
└── includes/                       # Core PHP classes & modules
    β”œβ”€β”€ class-wca-activator.php      # Activation setup & DB migrations
    β”œβ”€β”€ class-wca-autoloader.php     # Class autoloader
    β”œβ”€β”€ class-wca-constants.php      # Namespace, TTL, and config constants
    β”œβ”€β”€ class-wca-deactivator.php    # Deactivation cleanup
    β”œβ”€β”€ admin/                       # Admin screens & user table integration
    β”‚   β”œβ”€β”€ class-wca-admin-user-tools.php
    β”‚   β”œβ”€β”€ class-wca-email-test-controller.php
    β”‚   β”œβ”€β”€ class-wca-log-viewer.php
    β”‚   β”œβ”€β”€ class-wca-login-notify.php
    β”‚   β”œβ”€β”€ class-wca-network-admin.php
    β”‚   β”œβ”€β”€ class-wca-settings.php
    β”‚   └── class-wca-user-table-columns.php
    β”œβ”€β”€ api/                         # REST API endpoints (custom-auth/v1)
    β”‚   β”œβ”€β”€ class-wca-api-router.php
    β”‚   └── endpoints/
    β”‚       β”œβ”€β”€ class-wca-endpoint-add-phone.php
    β”‚       β”œβ”€β”€ class-wca-endpoint-login.php
    β”‚       β”œβ”€β”€ class-wca-endpoint-otp.php
    β”‚       β”œβ”€β”€ class-wca-endpoint-password.php
    β”‚       β”œβ”€β”€ class-wca-endpoint-profile.php
    β”‚       └── class-wca-endpoint-register.php
    β”œβ”€β”€ auth/                        # Authentication core logic
    β”‚   β”œβ”€β”€ class-wca-auth-engine.php
    β”‚   β”œβ”€β”€ class-wca-identifier-resolver.php
    β”‚   └── class-wca-session-manager.php
    β”œβ”€β”€ checkout/                    # WooCommerce checkout field locking & protection
    β”‚   β”œβ”€β”€ class-wca-checkout-field-locker.php
    β”‚   └── class-wca-checkout-guard.php
    β”œβ”€β”€ email/                       # Email dispatch & template engine
    β”‚   β”œβ”€β”€ class-wca-email-client.php
    β”‚   └── class-wca-template-engine.php
    β”œβ”€β”€ integrations/                # External integrations
    β”‚   └── class-wca-textmagic-client.php
    β”œβ”€β”€ logging/                     # Audit logging
    β”‚   └── class-wca-logger.php
    β”œβ”€β”€ migration/                   # User account migration tools
    β”‚   └── class-wca-account-migrator.php
    β”œβ”€β”€ otp/                         # OTP generation, dispatching, and validation
    β”‚   β”œβ”€β”€ class-wca-otp-dispatcher.php
    β”‚   β”œβ”€β”€ class-wca-otp-generator.php
    β”‚   └── class-wca-otp-validator.php
    β”œβ”€β”€ profile/                     # Profile verification & updating
    β”‚   β”œβ”€β”€ class-wca-profile-update-manager.php
    β”‚   └── class-wca-profile-verifier.php
    β”œβ”€β”€ registration/                # Pre-database registration pipeline
    β”‚   β”œβ”€β”€ class-wca-registration-completer.php
    β”‚   β”œβ”€β”€ class-wca-registration-pipeline.php
    β”‚   └── class-wca-registration-validator.php
    β”œβ”€β”€ security/                    # Security guards & rate limiters
    β”‚   β”œβ”€β”€ class-wca-rate-limiter.php
    β”‚   β”œβ”€β”€ class-wca-recaptcha.php
    β”‚   β”œβ”€β”€ class-wca-registration-guard.php
    β”‚   └── class-wca-sanitizer.php
    └── transient/                   # Encrypted transient store & cleanup janitor
        β”œβ”€β”€ class-wca-transient-janitor.php
        └── class-wca-transient-store.php

πŸ“‘ REST API Routes

All endpoints are registered under namespace custom-auth/v1:

πŸ“ Registration

  • POST /wp-json/custom-auth/v1/register/initiate - Initiates registration, validates input, stores transient payload, dispatches OTP.
  • GET, POST /wp-json/custom-auth/v1/register/verify-email - Verifies email magic token.
  • POST /wp-json/custom-auth/v1/register/verify-sms - Verifies SMS OTP code.
  • POST /wp-json/custom-auth/v1/register/complete - Finalizes account creation into wp_users and sets auth cookies.

πŸ”‘ Authentication

  • POST /wp-json/custom-auth/v1/login/check-identifier - Resolves identifier (email, username, phone).
  • POST /wp-json/custom-auth/v1/login/send-otp - Dispatches OTP for passwordless login.
  • POST /wp-json/custom-auth/v1/login/authenticate - Authenticates user via password or OTP code.

πŸ”“ Password Reset & Profile

  • POST /wp-json/custom-auth/v1/password/forgot - Initiates password reset flow.
  • POST /wp-json/custom-auth/v1/password/verify-otp - Verifies reset OTP code.
  • POST /wp-json/custom-auth/v1/password/reset - Sets new password.
  • POST /wp-json/custom-auth/v1/profile/update-initiate - Triggers contact update with re-verification.
  • POST /wp-json/custom-auth/v1/profile/verify-update - Verifies profile update OTP code.

βš™οΈ Requirements & Installation

System Requirements

  • WordPress: 6.0 or higher
  • WooCommerce: 7.0 or higher
  • PHP: 8.1 or higher

Installation

  1. Clone or copy the plugin to your WordPress plugins directory:
    cd wp-content/plugins/
    git clone https://github.com/malikad778/woocommerce-otp-auth-engine.git wca-auth-engine
  2. Activate WCA Auth Engine via Plugins > Installed Plugins (or Network Activate on Multisite).
  3. Configure TextMagic credentials, Email settings, and custom options in WCA Auth Engine > Settings.

πŸ“„ License

Distributed under the GPLv2 or later License. See LICENSE for more information.


πŸ‘¨β€πŸ’» Author

Developed with ❀️ by Adnan Haider.

About

Unified WooCommerce & WordPress authentication engine featuring pre-DB OTP registration gating (SMS & Email), SMS pumping/AIT fraud defense, REST API modals, and multisite support.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages