PHP code example of gabrielesbaiz / nova-two-factor
1. Go to this page and download the library: Download gabrielesbaiz/nova-two-factor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gabrielesbaiz / nova-two-factor example snippets
return [
'enabled' => env('NOVA_TWO_FA_ENABLE', true),
'mandatory' => env('NOVA_TWO_FA_MANDATORY', false),
'user_table' => 'users',
'user_id_column' => 'id',
'connection_name' => env('DB_CONNECTION'),
/* Encrypt the google secret values saved in database */
'encrypt_google2fa_secrets' => false,
/* QR code can be generate using Google API or inbuilt 'BaconQrCode' package */
'use_google_qr_code_api' => true,
'user_model' => App\Models\User::class,
/* Change visibility of Nova Two Fa menu in right sidebar */
'showin_sidebar' => true,
'menu_text' => 'Two FA',
'menu_icon' => 'lock-closed',
/* Exclude any routes from 2fa security */
'except_routes' => [],
/*
* reauthorize these urls before access, within given timeout
* you are allowed to use wildcards pattern for url matching
*/
'reauthorize_urls' => [
// 'nova/resources/users/new',
// 'nova/resources/users/*/edit',
],
/* timeout in minutes */
'reauthorize_timeout' => 5,
];
namespace App\Models;
use Gabrielesbaiz\NovaTwoFactor\ProtectWith2FA;
class User extends Authenticatable{
use ProtectWith2FA;
}
/*
|--------------------------------------------------------------------------
| Nova Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Nova route, giving you the
| chance to add your own middleware to this stack or override any of
| the existing middleware. Or, you can just stick with this stack.
|
*/
'middleware' => [
...
\Gabrielesbaiz\NovaTwoFactor\Http\Middleware\TwoFa::class
],
class NovaServiceProvider extends NovaApplicationServiceProvider{
public function tools()
{
return [
...
new \Gabrielesbaiz\NovaTwoFactor\NovaTwoFactor()
];
}
}