chrysanthos/laravel-otp

Login Otp for Laravel

0.2.0 2023-01-30 17:14 UTC

This package is auto-updated.

Last update: 2023-01-30 17:15:58 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.