adevesa/laravel-simple-otp
Laravel Simple OTP
This package is a simple OTP generator for Laravel. You can use it to generate OTPs and validate them.
Installation
You can install the package via composer:
composer require adevesa/laravel-simple-otp
You can publish and run the migrations and publish the config file with:
php artisan vendor:publish --provider="adevesa\SimpleOTP\SimpleOTPServiceProvider"
php artisan migrate
This is the contents of the published config file:
return [
'otp_length' => env('SIMPLE_OTP_LENGTH', 6),
'otp_format' => env('SIMPLE_OTP_FORMAT', 'alpha_numeric'),
'otp_expiration_minutes' => env('SIMPLE_OTP_EXPIRATION_MINUTES', 5),
'otp_max_attempts' => env('SIMPLE_OTP_MAX_ATTEMPTS', 3),
'otp_throw_exceptions' => env('SIMPLE_OTP_THROW_EXCEPTIONS', true),
];
With the otp_throw_exceptions option you can control if the package should throw exceptions or return false when an OTP is not valid.
Usage
$simpleOTP = new adevesa\SimpleOTP();
$code = $simpleOTP->create('a_email@example.com');
$simpleOTP->verify('a_email@example.com', "ASD123");
Or also
$code = \adevesa\SimpleOTP\Facades\SimpleOTP::create('+5491123456789')->code;
$isValid = \adevesa\SimpleOTP\Facades\SimpleOTP::verify('+5491123456789', $code);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover any security-related issues, please email adevesa95@outlook.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Passwordless email magic-link & OTP authentication for Laravel — standalone or w...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0.2 | ^8.1 | ^10.0 | MIT | |
| 1.0.1 | ^8.1 | ^10.0 | MIT | |
| 1.0.0 | ^8.1 | ^10.0 | MIT |