rezak/otp-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rezak/otp-auth

Composer 安装命令:

composer require rezak/otp-auth

包简介

A Laravel package for OTP endpoint implementation

README 文档

README

Latest Version on Packagist Total Downloads

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

  1. Publish the configuration and language files:
php artisan vendor:publish --provider="RezaK\OtpAuth\Providers\OtpAuthServiceProvider"
  1. Add your SMS gateway service to the SMSSenderInterface implementation.

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-15