Download the PHP package scriptoshi/livewire-otp-auth without Composer
On this page you can find all versions of the php package scriptoshi/livewire-otp-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download scriptoshi/livewire-otp-auth
More information about scriptoshi/livewire-otp-auth
Files in scriptoshi/livewire-otp-auth
Package livewire-otp-auth
Short Description OTP authentication for Laravel with Livewire
License MIT
Informations about the package livewire-otp-auth
Livewire OTP Authentication
A simple and easy-to-use OTP (One-Time Password) Email authentication package for Laravel 12 using Livewire 3.
Features
- OTP-based authentication for your Laravel application
- Simple email-based verification
- Support for login, registration, and email validation flows
- Rate limiting for OTP requests
- Customizable expiration times
- Responsive UI with live input validation using Flux components
- Easy integration with existing Laravel applications
Requirements
- PHP 8.2+
- Laravel 12.x
- Livewire 3.x
- Flux 2.x
Installation
You can install the package via composer:
This will automatically install Livewire and Flux if they're not already in your project.
After installing the package, you need to run the migrations:
This will add the necessary columns to your users table.
Configuration
You can publish the configuration file:
This will create a livewire-otp-auth.php
file in your config
directory. You can modify the following settings:
- expiration_time: How long an OTP is valid for in minutes (default: 10)
- otp_length: The length of the OTP code (default: 6)
- resend_cooldown: Cooldown time in seconds before a user can request another OTP (default: 60)
- rate_limit_attempts: Number of OTP attempts before rate limiting is applied (default: 5)
- rate_limit_duration: Duration in minutes for which rate limiting is applied (default: 5)
Usage
1. Add the trait to your User model
First, add the HasOtpAuth
trait to your User model:
2. Make sure Flux is properly set up
If you haven't already set up Flux in your project, follow the official Flux documentation to make sure it's properly configured.
3. Add the component to your views
You can now add the OTP authentication component to your views:
By default, this will use the login
type and the request
step. You can customize this by passing parameters:
Available types:
login
: For existing users (default)register
: For new users (requires a name field)validate
: For validating emails of logged-in users
4. Customizing the UI
If you want to customize the UI, you can publish the views:
Then you can edit the views in resources/views/vendor/livewire-otp-auth
.
5. Configure Tailwind CSS
To ensure that Tailwind CSS properly processes the component styles, add this package to your content sources in your CSS file (typically resources/css/app.css
):
For example, your CSS file might look similar to this:
6. Flux Components
This package uses Flux components to provide a consistent and beautiful UI. The components include:
flux:input
- Used for email and name inputsflux:button
- Used for action buttons
These components automatically inherit your application's theme and styling, providing a seamless integration with your Laravel application.
Routes
The package automatically registers a route for verifying OTPs via email links:
This route is named otp.verify
and can be used to verify OTPs sent via email.
License
The MIT License (MIT). Please see License File for more information.
All versions of livewire-otp-auth with dependencies
illuminate/support Version ^12.0
illuminate/database Version ^12.0
illuminate/notifications Version ^12.0
livewire/livewire Version ^3.0
livewire/flux Version ^2.0