This example provides a complete OTP (One-Time Password) authentication system built on Payload CMS. It includes endpoints for generating and verifying OTP codes.
-
Clone the repository:
-
Copy the environment file:
cp .env.example .env- Install dependencies and start the development server:
pnpm install
pnpm dev- Open your browser and navigate to http://localhost:3000/admin
- Create an admin account and a user account
Here's how to use it:
POST /api/auth/otp/generate
Content-Type: application/json
{
"email": "user@example.com"
}POST /api/auth/otp/verify
Content-Type: application/json
{
"email": "user@example.com",
"otp": "1234"
}For more details, check: