PHP code example of brackets / verifications

1. Go to this page and download the library: Download brackets/verifications 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/ */

    

brackets / verifications example snippets


    'enabled' => env('VERIFICATION_ENABLED', true),                     // you can enable/disable globally (i.e. disabled for tests/dev env)
    'actions' => [
        'my-action' => [
            'enabled' => true,                                          // you can enable/disable single action
            'channel' => 'sms',                                         // currently: sms, email
            'form_template' => 'brackets/verifications::verification',  // blade name with namespace used for verification code form
            'expires_in' => 15,                                         // specifies how many minutes does it take to 

Route::middleware('verifications.verify:{my-action}')

    'enabled' => env('VERIFICATION_ENABLED', true),
    'actions' => [
        'money-balance' => [
            'enabled' => true,
            'channel' => 'sms',
            'form_template' => 'brackets/verifications::verification',
            'expires_in' => 15,
            'expires_from' => 'verification',
            'code' => [
                'type' => 'numeric',
                'length' => 6,
                'expires_in' => 10,
            ]
        ]
    ]

Route::get('/{account}/money-balance', 'MoneyController@moneyBalance')
    ->name('money-balance')
    ->middleware('verifications.verify:money-balance');

Route::post('/{account}/money-withdraw', 'MoneyController@moneyWithdraw')
    ->name('money-withdraw')
    ->middleware('verifications.verify:money-withdraw');

Route::get('/{account}/money-withdraw', 'MoneyController@moneyWithdrawForm')
    ->name('money-withdraw-form')
    ->middleware('verifications.verify:money-withdraw');

Route::post('/{account}/money-withdraw', 'MoneyController@moneyWithdraw')
    ->name('money-withdraw')
    ->middleware('verifications.verify:money-withdraw');

Route::middleware(['verifications.verify:money-balance'])->group(static function () {
    Route::get('/{account}/money-balance', 'MoneyController@moneyBalance')
        ->name('money-balance');
        
    Route::get('/{account}/money-withdraw', 'MoneyController@moneyWithdrawAutoConfirmator')
        ->name('money-withdraw-auto-confirmator');
        
    Route::post('/{account}/money-withdraw', 'MoneyController@moneyWithdraw')
        ->name('money-withdraw');
    // ...
});

public function postDownloadInvoice(Invoice $invoice)
{
    // this code will run on the attempt before the verification and then again, after the successful verification
    if (!$invoice->isPublished()) {
        throw new InvoiceNotPublishedException();  
    }  

    return Verification::verify('download-invoice',             // name of the action
                                '/invoices',                    // URL user will be redirect after verification (he must click to download the invoice again manually :( 
                                function () use ($invoice) {
                                    // on the other hand this code will run only once, after the verification
                                    return $invoice->download();
                                });
}

php artisan vendor:publish --provider="Brackets\Verifications\VerificationServiceProvider" --tag="views"

class User extends Authenticatable implements Verifiable
{
    use VerifiableTrait;
    // ...

    public function isVerificationRequired($action) {
    
        // allow super admin to all actions
        if ($this->hasRole('Admin') {
            return false;
        }
    
        if ($action == 'withdraw-money') {
            // allow withdraw-money action to be optional (i.e. user can set it in their profile)
            if (!$this->withdraw_monoey_

    'actions' => [
        '2FA' => [
            'enabled' => true,
            'channel' => 'sms',
            'expires_in' => 15,
            'expires_from' => 'last_activity', 
            'code' => [
                // ...
            ],
        ],
    ]

Route::middleware([‘verifications.verify:2FA’])->group(function() {

    // all your routes goes here
    
})