LaravelPackages.net
Acme Inc.
Toggle sidebar
rezak/otp-auth

A Laravel package for OTP endpoint implementation

1
0
About rezak/otp-auth

rezak/otp-auth is a Laravel package for a laravel package for otp endpoint implementation. It currently has 0 GitHub stars and 1 downloads on Packagist. Install it with composer require rezak/otp-auth. Discover more Laravel packages by rezak or browse all Laravel packages to compare alternatives.

Last updated

OTP Authentication Package for Laravel

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.

Comments