chrysanthos / laravel-otp
Login Otp for Laravel
Requires
- php: ^8.1.0|^8.2.0
- illuminate/contracts: ^9.0|^10.0
- laravel/framework: ^9.41|^10.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
README
This package lets you set up OTP verification on whenever a user is logged in.
Installation
You can install the package via composer:
composer require chrysanthos/laravel-otp
You can publish the config file with:
php artisan vendor:publish --tag="laravel-otp-config"
This is the contents of the published config file:
return [ 'enabled' => false, 'notification' => \Chrysanthos\LaravelOtp\Notifications\SendOtpToUserNotification::class, ];
Optionally, you can publish the login view using
php artisan vendor:publish --tag="laravel-otp-views"
Usage
Add the RedirectToOtpPage Middleware to the routes you wish to be protected by OTP.
Route::middleware([ 'auth:sanctum', RedirectToOtpPage::class, ])->group(function () { Route::get('/dashboard', DashboardController::class); });
Customize the notification you wish to be sent by changing the notification key in the config. By setting the notification to a custom notification class you have full flexibility on how the notification is sent (Channels, Text, etc.)
'notification' => \App\Notifications\YourCustomNotification::class,
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please contact me directly via email.
Credits
License
The MIT License (MIT). Please see License File for more information.