payloadcms-2fa-auth

Demonstrates implementing 2FA (TOTP) with custom fields and endpoints.

1 Mar 18, 2026

Overview

Example implementation of two-factor authentication using time-based one-time passwords (TOTP) for Payload CMS. Demonstrates adding a custom UI field to a user collection, creating REST endpoints for QR code generation and token verification, and integrating MFA into the Payload login flow. Includes getQRCode, verifyKeyCode functions and a custom MFAButton component.