Package Data | |
---|---|
Maintainer Username: | codingquark |
Maintainer Contact: | quark@codingquark.com (Dhavan Vaidya) |
Package Create Date: | 2016-11-14 |
Package Last Update: | 2021-12-02 |
Language: | PHP |
License: | GPL |
Last Refreshed: | 2024-11-08 03:14:04 |
Package Statistics | |
---|---|
Total Downloads: | 3,553 |
Monthly Downloads: | 5 |
Daily Downloads: | 0 |
Total Stars: | 18 |
Total Watchers: | 2 |
Total Forks: | 9 |
Total Open Issues: | 6 |
Laravel 5 OTP Generation.
The module generates OTPs and validates them. You can plug your own notifier (such as AWS SNS) to send the OTPs to various channels.
Several configuration options are provided:
composer require fleetfoot/otp
Fleetfoot\OTP\OTPServiceProvider
to your providers array in config/app.php
composer dump-autoload
php artisan vendor:publish
php artisan migrate
Done!
The package publishes config/otp.php
. It is well documented.
The package provides with the following helpers:
Manager
Generator
Validator
You can use Manager
to interact with the whole module. It acts as a wrapper for the complete functionality. However, you are free to use other helpers to generate and validate the OTPs.
To generate an OTP, call generate
method of Manager
. This takes two arguments: module and ID. Both are strings. You can pass anything here, but keep in mind that this combination will be used to validate the OTP.
For e.g. $manager->generate('users', '1')
will return an OTP for the combination of 'users' module and ID '1'.
To validate, call isValid()
of the manager. It will return boolean based on the validity of the OTP.
Validation makes sure the module + ID is not blocked, and the token is not expired.
Whenever the module + ID exceeds the maximum allowed (non-expired) OTPs, they will be blocked. You won't be able to generate anymore OTPs for that module + ID combination.
Currently, there is no interface to unblock the clients. You need to manually remove the entry from the table otp_blacklist
. Please check ToDo to check progress and thoughts on this feature.
The manager gives notify()
method which accepts any implementation of Notifier
interface. You can implement this interface as per your business logic.
You might want to call useOtp()
of the manager after the varification process completes. If you do not call this method, OTP will remain valid till it reaches its expiry limit.
All contributions are welcome! Create a fork, create PRs, discuss!