otp-generator

所属分类:其他
开发工具:PHP
文件大小:0KB
下载次数:0
上传日期:2021-12-12 16:30:56
上 传 者sh-1993
说明:  Laravel OTP发生器,
(Laravel OTP Generator,)

文件列表:
.php-cs-fixer.cache (2609, 2023-10-22)
.php_cs.dist.php (1281, 2023-10-22)
CHANGELOG.md (126, 2023-10-22)
LICENSE.md (1090, 2023-10-22)
composer.json (1441, 2023-10-22)
config/ (0, 2023-10-22)
config/otp-generator.php (2489, 2023-10-22)
database/ (0, 2023-10-22)
database/migrations/ (0, 2023-10-22)
database/migrations/create_otps_table.php.stub (713, 2023-10-22)
src/ (0, 2023-10-22)
src/Models/ (0, 2023-10-22)
src/Models/Otp.php (917, 2023-10-22)
src/Otp.php (225, 2023-10-22)
src/OtpGenerator.php (5397, 2023-10-22)
src/OtpServiceProvider.php (1304, 2023-10-22)

# OTP Generator and Validator for Laravel Applications [![Latest Version on Packagist](https://img.shields.io/packagist/v/seshac/otp-generator.svg?style=flat-square)](https://packagist.org/packages/seshac/otp-generator) ![GitHub Tests Action Status](https://github.com/seshac/otp-generator/workflows/Tests/badge.svg) [![Total Downloads](https://img.shields.io/packagist/dt/seshac/otp-generator.svg??style=flat-square)](https://packagist.org/packages/seshac/laravel-shiprocket-api) ## Installation You can install the package via composer: ```bash composer require seshac/otp-generator ``` You can publish and run the migrations with: ```bash php artisan vendor:publish --provider="Seshac\Otp\OtpServiceProvider" --tag="migrations" php artisan migrate ``` You can publish the config file with: ```bash php artisan vendor:publish --provider="Seshac\Otp\OtpServiceProvider" --tag="config" ``` ## Usage ```php use Seshac\Otp\Otp; . . $otp = Otp::generate($identifier); . $verify = Otp::validate($identifier, $otp->token); // example response { "status": true "message": "OTP is valid" } // to get an expiredAt time $expires = Otp::expiredAt($identifier); // example response { +"status": true +"expired_at": Illuminate\Support\Carbon @1611895244^ { .... #dumpLocale: null date: 2021-01-29 04:40:44.0 UTC (+00:00) } ``` You have control to update the setting at otp-generator.php config file but you control while generating also ## Advance Usage ```php use Seshac\Otp\Otp; . . $otp = Otp::setValidity(30) // otp validity time in mins ->setLength(4) // Lenght of the generated otp ->setMaximumOtpsAllowed(10) // Number of times allowed to regenerate otps ->setOnlyDigits(false) // generated otp contains mixed characters ex:ad2312 ->setUseSameToken(true) // if you re-generate OTP, you will get same token ->generate($identifier); . $verify = Otp::setAllowedAttempts(10) // number of times they can allow to attempt with wrong token ->validate($identifier, $otp->token); ``` ## Testing ```bash composer test ``` ## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Contributing Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. ## Security Vulnerabilities Please review [our security policy](../../security/policy) on how to report security vulnerabilities. ## Credits - [sesha](https://github.com/seshac) - [All Contributors](../../contributors) ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

近期下载者

相关文件


收藏者