PHP code example of wnx / laravel-tfa-confirmation
1. Go to this page and download the library: Download wnx/laravel-tfa-confirmation 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/ */
wnx / laravel-tfa-confirmation example snippets
use Wnx\TfaConfirmation\Http\Controllers\ConfirmTwoFactorAuthenticationCodeController;
use Wnx\TfaConfirmation\Http\Controllers\TwoFactorAuthenticationChallengeController;
use Wnx\TfaConfirmation\Http\Responses\DefaultJsonResponse;
return [
/**
* Enable or disable two-factor authentication confirmation.
*/
'enabled' => env('TFA_CONFIRMATION_ENABLED', true),
/**
* The session key that is used to store the timestamp of the last time
* the user confirmed their two-factor authentication code.
*/
'session_key' => 'auth.two_factor_confirmed_at',
/**
* The amount of time in seconds the confirmation is valid.
* Users will not be asked to enter their two-factor authentication code again for this amount of time.
*/
'timeout' => env('TFA_CONFIRMATION_TIMEOUT', 60 * 60 * 24), // 24 hours
/**
* The view that should be returned when the user needs to confirm their two-factor authentication code.
* You should publish the views to your application to customize the challenge view.
*/
'challenge_view' => 'tfa-confirmation::challenge',
/**
* Controller used to show the two-factor authentication challenge view.
*/
'challenge_controller' => TwoFactorAuthenticationChallengeController::class,
/**
* Controller used to confirm the two-factor authentication code entered by the user on the challenge view.
* If you customize this controller, make sure to dispatch the `\Laravel\Fortify\Events\ValidTwoFactorAuthenticationCodeProvided` event.
*/
'confirmation_controller' => ConfirmTwoFactorAuthenticationCodeController::class,
/**
* The response that should be returned when the user needs to confirm their
* two-factor authentication code, but the request expects a JSON response.
*/
'json_response' => DefaultJsonResponse::class,
];
// routes/web.php
// Protect a single route
Route::get('/super-important-route', SuperImportantController::class)
->middleware([
// Use Middleware directly
\Wnx\TfaConfirmation\Http\Middleware\RequireTwoFactorAuthenticationConfirmation::class,
// Use Middleware alias
'