rezak/otp-auth
Composer 安装命令:
composer require rezak/otp-auth
包简介
A Laravel package for OTP endpoint implementation
README 文档
README
This package provides an OTP-based authentication system for Laravel applications, including SMS-based OTP generation and verification.
Features
- Generate OTPs and send via SMS
- Verify OTPs for authentication
- Easy to integrate into any Laravel application
Installation
You can install the package via composer:
composer require rezak/otp-auth
Configuration
- Publish the configuration and language files:
php artisan vendor:publish --provider="RezaK\OtpAuth\Providers\OtpAuthServiceProvider"
- Add your SMS gateway service to the
SMSSenderInterfaceimplementation.
Usage
Routes
The package automatically registers the following routes:
- POST
/api/auth/otp/send- Send OTP to a mobile number. - POST
/api/auth/otp/verify- Verify OTP for a mobile number.
Example Request
Sending OTP
curl -X POST \ -H "Content-Type: application/json" \ -d '{"mobile_number": "09123456789"}' \ http://your-app-url/api/auth/otp/send
Verifying OTP
curl -X POST \ -H "Content-Type: application/json" \ -d '{"mobile_number": "09123456789", "otp": "123456"}' \ http://your-app-url/api/auth/otp/verify
Testing
Run the tests with:
composer test
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-15