This package is sending out a 6 digit verification code per email, when a user visits a route in your Laravel app. By default, the user identity verification will be valid for 30 minutes.
- Install the package via composer:
composer require viezel/otp
php artisan vendor:publish --provider="Viezel\OTP\OTPServiceProvider" --tag="migrations"
php artisan migrate
- Add Middleware
check_otp
to the routes that should verify the User Identity.
Route::get('some/protected/route', MyController::class)->middleware(['auth', 'check_otp']);
Route::get('other/route', MyOtherController::class)->middleware(['auth', 'check_otp']);
You can publish the config file with:
php artisan vendor:publish --provider="Viezel\OTP\OTPServiceProvider" --tag="otp-config"
return [
/*
* How long time in minutes should the verification code be valid for
*/
'link_expires_in_minutes' => 300,
/*
* How long time in minutes should the user be verified for the certain route
*/
'validation_expires_after_minutes' => 30,
/*
* Should be use the queue to sent out the verification email
*/
'use_queue' => false,
/*
* Route Prefix
*/
'route_prefix' => '',
/*
* Route Middleware
*/
'route_middleware' => ['web', 'auth'],
];
You can build up your own verification view. Just publish the views and change what you need.
The package provides a blade component to reuse. Its based on Alpine.js and Tailwind CSS.
<x-otp::pincode url="{{ $url }}"></x-otp::pincode>
composer test
The MIT License (MIT). Please see License File for more information.