Download the PHP package ichtrojan/laravel-otp without Composer
On this page you can find all versions of the php package ichtrojan/laravel-otp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ichtrojan/laravel-otp
More information about ichtrojan/laravel-otp
Files in ichtrojan/laravel-otp
Package laravel-otp
Short Description A simple package to generate and validate OTPs
License MIT
Informations about the package laravel-otp
Laravel OTP โฒ
Introduction ๐
This is a simple package to generate and validate OTPs (One Time Passwords). This can be implemented mostly in Authentication.
Installation ๐ฝ
Install via composer
Run Migrations
Usage ๐งจ
NOTE Response are returned as objects. You can access its attributes with the arrow operator (
->
)
Generate OTP
$identifier
: The identity that will be tied to the OTP.$type
: The type of token to be generated, supported types arenumeric
andalpha_numeric
$length (optional | default = 4)
: The length of token to be generated.$validity (optional | default = 10)
: The validity period of the OTP in minutes.
Sample
This will generate a six digit OTP that will be valid for 15 minutes and the success response will be:
Validate OTP
$identifier
: The identity that is tied to the OTP.$token
: The token tied to the identity.
Sample
Responses
On Success
Does not exist
**Not Valid***
Expired
Check The validity of an OTP
To verify the validity of an OTP without marking it as used, you can use the isValid
method:
This will return a boolean value of the validity of the OTP.
Delete expired tokens
You can delete expired tokens by running the following artisan command:
You can also add this artisan command to app/Console/Kernel.php
to automatically clean on scheduled
Contribution
If you find an issue with this package or you have any suggestion please help out. I am not perfect.