Download the PHP package coucounco/laravel-otc without Composer
On this page you can find all versions of the php package coucounco/laravel-otc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coucounco/laravel-otc
More information about coucounco/laravel-otc
Files in coucounco/laravel-otc
Package laravel-otc
Short Description Laravel One Time Code Authentication
License MIT
Homepage https://github.com/coucounco/laravel-otc
Informations about the package laravel-otc
Laravel One Time Code Authentication
Laravel One Time Code Authentication allow you to send by mail an one time code to auth your users.
Installation
You can install the package via composer:
Run the installer
Configuration
Edit config/otc.php
notifier_class
Define what class will be called to send the notification. By default it use the Notification facade of Laravel.
notification_class
Define what notification will be sent.
You can replace this class by any other notification, you will recieve a OtcToken $token
as constructor parameters
You can access the code that need to be sent from the $token
variable
authenticatables
This array will define a list of entites that can be used to get authentified. It's like a simplified version of laravel guard. I might move this to guard in the futur. The main goal is to set what model and what column are used to find the model in the database.
user
is the name of the "guard"/typemodel
is the corresponding eloquent modelidentifier
is the identifier column that will be used to find the corresponding user
Usage
Check
Check if the user is authenticated
This method will return
true
orfalse
.
If the user is not authentified you can return an error
This response will return 401 http error with the following body.
You must use the request_code_url
as the url to request a code (ye seem obvious) and you must pass the request_code_body
as the body in json format !
Request a code
Send a post request
with body
You need to send the
type
and theidentifier
of your authenticatables entity
An email will be sent to the corresponding entity if available. The email will contain the code.
Request a token
Send a post request
with body
You need to send the
code
that should have been retrieved from the user through a form or anything else.
You will recieve a token back
And you can use this token for every further request.
Authentified request
When you have the token, you can send it with you request to be authentified.
Pass it in the headers
Or in the query string
Troubleshooting
CORS
If you use fruitcake/laravel-cors
to manage CORS in your app. You will get CORS error
when doing call to this package endpoints.
You will need to add a new path in your config/cors.php
in the paths
array
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please use the issue tracker.
Credits
- coucounco
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-otc with dependencies
spatie/laravel-package-tools Version ^1.13.0
illuminate/contracts Version ^10.0