Download the PHP package cuongnd88/otp-auth without Composer
On this page you can find all versions of the php package cuongnd88/otp-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cuongnd88/otp-auth
More information about cuongnd88/otp-auth
Files in cuongnd88/otp-auth
Package otp-auth
Short Description Laravel OTP Authentication (One Time Passwords)
License MIT
Homepage https://github.com/cuongnd88/otp-auth
Informations about the package otp-auth
Laravel OTP AUTH
This package allows you to authenticate with one time password access (OTP).
Example Usage:
Contents
- Installation
- Usage
- Generate OTP
- Verify OTP
- Basic identification
- Demo
- Credits
Installation
1- Add the package to your dependencies.
2- Run the command:
Example:
SendOtp
class and HasOtpAuth
trait are auto-generated at app/Authentication
directory.
CreateNotificationsTable
class is alseo auto-generated at app/database/migrations
.
3- Apply the migrations:
It will create a table called notifications
to store generated OTP information.
Usage
Generate OTP
You can generate OTP via email or SMS
This package allows you to alter OTP length and lifetime
OTP default length: The default length is 6
.
OTP default lifetime: The default lifetime is 1
minute.
There is the detail of auto-generate SentOTP
class:
toTwilio: This method is implemented by importing delivery-channels.
Verify OTP
After sent OTP via your configed methods, you call authByOtp
to authenticate
Based on your credentials, you might authenticate with email or phone number
Set up the credentials:
In this case, you can apply User
model which must use HasOtpAuth
trait
Let see more detail HasOtpAuth
trait
Basic identification
In some cases, you just need to identify the right access, you might need to execute checkOtp
method
Demo
This is demo soure code. Laravel Colab
Credits
- Ngo Dinh Cuong