Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
stanfortonski committed Jan 31, 2021
1 parent d7a3327 commit e9a853d
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# Laravel-Twofactor
Two-factor authentication package for Laravel 7.x, 8.x via e-mail.
Two-factor authentication package for Laravel 7.x and 8.x via e-mail.

# Information
This package provides you to set of middleware, view, migration, routes with controllers, transaltions and methods to user model which allow you to set up 2FA vie email for your application.

# Installation
1. First install package via composer. Run `composer require stanfortonski/laravel-twofactor`.
2. Setup provider. In config/app.php add following code to bottom of providers:
```php
'providers' => [
//...
Stanfortonski\Laraveltwofactor\ServiceProvider::class
],
```
3. Setup middleware. In app/Http/Kernel.php add following code to bottom of middlewares:
```php
protected $routeMiddleware = [
//...
'twofactor' => \Stanfortonski\Laraveltwofactor\Middleware\TwoFactor::class
];
```
4. You have to publish config file twofactor.php. Run command: `php artisan vendor:publish --provider="Stanfortonski\Laraveltwofactor\ServiceProvider"`.
5. Run `php artisan migrate`.
6. Add line `$user->startTwoFactor()` in your login process. For example in Laravel/ui add this line in Auth\LoginController@authenticated method before redirect.
7. Set up your email in .env.

# Configuration
In config/twofactor.php
1. If you want to disable twofactor/preferences routes set `preferences.allow` to false.
2. If you want to change expire time of 2FA code you will change `expire_duration`. Default value is 15 minutes.
3. Look at routes.login, routes.successful and routes.return that must be real routes name in your application. More in file itself.

# Usage
You have to set twofactor middleware in routes. The way depends on you.

Example:
```php
Route::get('/home', function(){
return view('home');
})->middleware(['auth', 'twofactor']);
```

0 comments on commit e9a853d

Please sign in to comment.