PHP code example of geoffry304 / yii2-authy

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

    

geoffry304 / yii2-authy example snippets

 yii migrate --migrationPath=@vendor/geoffry304/yii2-authy/migrations

// app/config/web.php
return [
    'modules' => [
        'authy' => [
            'class' => 'geoffry304\authy\Module',
            'api_key' => 'here your api key from authy',
            'send_mail_from => '[email protected]'
        ],
        'user' => [
            'class' => 'amnah\yii2\user\Module',
            'modelClasses' => [
                'LoginForm' => 'geoffry304\authy\forms\LoginForm'
            ]
        ],
    ],
];

$module2FA = Yii::$app->getModule('authy');
if ($module2FA) {
    Yii::$app->session->set('credentials', ['login' => $model->email, 'pwd' => $model->password, 'remember' => $rememberMe]);
    $returnUrl = $module2FA->validateLogin($model->getUser());
    return $returnUrl;  
}
 

// app/config/web.php
return [
    'bootstrap' => ['GlobalCheck'],
    'components' => [
        'GlobalCheck'=> [
            'class'=>'geoffry304\authy\components\GlobalCheck'
         ],
     ],
];