Download the PHP package raja-muhammad-asher/laravel-otp-mongodb without Composer
On this page you can find all versions of the php package raja-muhammad-asher/laravel-otp-mongodb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download raja-muhammad-asher/laravel-otp-mongodb
More information about raja-muhammad-asher/laravel-otp-mongodb
Files in raja-muhammad-asher/laravel-otp-mongodb
Package laravel-otp-mongodb
Short Description A simple package to generate and validate OTPs for mongodb/laravel-mongodb
License MIT
Informations about the package laravel-otp-mongodb
Laravel OTP for mongodb โฒ
Introduction ๐
This is a simple package to generate and validate OTPs (One Time Passwords). This can be implemented mostly in Authentication.
Thanks https://github.com/mongodb/laravel-mongodb.
Original https://github.com/ichtrojan/laravel-otp Thanks bud <3
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.