Laravel Packages

One-time Password Manager for Laravel

Published
One-time Password Manager for Laravel image

The One-time Password (OTP) Manager package for Laravel provides a comprehensive set of methods to generate, send, verify, and manage OTPs. It also integrates with Laravel's cache system to throttle OTP sending and provides a layer of security by tracking OTP requests:

use Salehhashemi\OtpManager\Facade\OtpManager;
 
// Send a OTP
OtpManager::send("1234567890");
 
// Resend a OTP
OtpManager::sendAndRetryCheck("1234567890");
 
// Verify a OTP
$isVerified = OtpManager::verify("1234567890", 123456, "uuid-string");
 
// Delete a verification code
OtpManager::deleteVerifyCode("1234567890");

Managing OTPs is at the core of this package. To help integrate and use OTPs, this package provides events so you can listen to OTP events and perform custom logic, such as sending the OTP via SMS to a user.

Main Features

  • Generate OTP codes
  • Send OTPs via mobile numbers
  • Resend OTPs with built-in throttling
  • Verify OTP codes
  • Track OTP requests
  • Rate limiting of OTP generation attempts (OtpRateLimiter middleware)
  • Otp Invalidation after multiple failed verifications
  • Automatic deletion of OTP codes after successful verification
  • Customize rate-limiting thresholds, max allowed attempts, and auto-delete
  • Supports multiple OTP types using enums
  • Customizable mobile number validation

The package's README has setup and usage examples. You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Related: Simple one-time password authentication in Laravel.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article