定制 elysiumrealms/laravel-otp 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

elysiumrealms/laravel-otp

最新稳定版本:1.2.1

Composer 安装命令:

composer require elysiumrealms/laravel-otp

包简介

A package to generate and validate OTP

README 文档

README

A module for generating and verifying OTPs.

Installation Guide

Install the package using Composer.

composer require elysiumrealms/laravel-otp

Publish the assets.

php artisan vendor:publish --tag=otp-assets

Run the migrations.

php artisan migrate

Implementation Guide

Schedule the otp:clean command to clean expired OTPs.

function schedule(Schedule $schedule)
{
    $schedule->command('otp:clean')
        ->onOneServer()
        ->everyFiveMinutes();
}

Usage Guide

Generate an for a mobile number.

curl -X POST http://localhost:8000/api/v1/otp/sms/generate \
    -H "Content-Type: application/json"
    -d '{"identifier": "1234567890"}'

Generate an OTP for an email address.

curl -X POST http://localhost:8000/api/v1/otp/mail/generate \
    -H "Content-Type: application/json"
    -d '{"identifier": "test@example.com"}'

Verify an OTP.

curl -X POST http://localhost:8000/api/v1/otp/validate \
    -H "Content-Type: application/json"
    -d '{"identifier": "1234567890", "token": "123456"}'

Verify an OTP for an email address.

curl -X POST http://localhost:8000/api/v1/otp/email/validate \
    -H "Content-Type: application/json"
    -d '{"identifier": "test@example.com", "token": "123456"}'

Check if identifier is verified with validator.

public function __invoke(Request $request)
{
    $request->validate([
        'identifier' => 'required|otp_verified',
    ]);
}

Check if identifier is verified.

if (\Elysiumrealms\Otp\Facades\Otp::verified('1234567890'))
    echo 'Identifier is verified';

For further details, please contact the development team.

统计信息

  • 总下载量: 391
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-27