LaravelPackages.net
Acme Inc.
Toggle sidebar
elysiumrealms/laravel-otp

A package to generate and validate OTP

391
0
1.2.1
About elysiumrealms/laravel-otp

elysiumrealms/laravel-otp is a Laravel package for a package to generate and validate otp. It currently has 0 GitHub stars and 391 downloads on Packagist (latest version 1.2.1). Install it with composer require elysiumrealms/laravel-otp. Discover more Laravel packages by elysiumrealms or browse all Laravel packages to compare alternatives.

Last updated

OTP Verification System

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": "[email protected]"}'

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": "[email protected]", "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.

Comments