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 SalehhashemiOtpManagerFacadeOtpManager;
// 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.
The post One-time Password Manager for Laravel appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest
Laravel articles like this directly in your inbox.
Source: Read MoreÂ