elysiumrealms / laravel-otp
A package to generate and validate OTP
Installs: 46
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
Requires
- php: >=7.1.0
- laravel-notification-channels/telegram: *
- laravel-notification-channels/twilio: *
- laravel/framework: ~5.5|~6.0|~7.0|~8.0|~9.0|~10.0
This package is auto-updated.
Last update: 2025-03-08 13:53:31 UTC
README
A module for generating and verifying OTPs.
Installation Guide
Install the package using Composer.
composer require elysiumrealms/laravel-otp
Publish the assets.
php artisan vendor:publish --tag=otp-assets
Run the migrations.
php artisan migrate
Implementation Guide
Schedule the otp:clean
command to clean expired OTPs.
function schedule(Schedule $schedule) { $schedule->command('otp:clean') ->onOneServer() ->everyFiveMinutes(); }
Usage Guide
Generate an for a mobile number.
curl -X POST http://localhost:8000/api/v1/otp/sms/generate \ -H "Content-Type: application/json" -d '{"identifier": "1234567890"}'
Generate an OTP for an email address.
curl -X POST http://localhost:8000/api/v1/otp/mail/generate \ -H "Content-Type: application/json" -d '{"identifier": "test@example.com"}'
Verify an OTP.
curl -X POST http://localhost:8000/api/v1/otp/validate \ -H "Content-Type: application/json" -d '{"identifier": "1234567890", "token": "123456"}'
Verify an OTP for an email address.
curl -X POST http://localhost:8000/api/v1/otp/email/validate \ -H "Content-Type: application/json" -d '{"identifier": "test@example.com", "token": "123456"}'
Check if identifier is verified with validator.
public function __invoke(Request $request) { $request->validate([ 'identifier' => 'required|otp_verified', ]); }
Check if identifier is verified.
if (\Elysiumrealms\Otp\Facades\Otp::verified('1234567890')) echo 'Identifier is verified';
For further details, please contact the development team.