Completed
Push — master ( 3df540...dcc87b )
by Andrii
05:56
created

ValidateMfaBehavior   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 18
ccs 0
cts 14
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A events() 0 6 1
A beforeLogin() 0 8 1
1
<?php
2
/**
3
 * Yii2 module providing multi-factor authentication
4
 *
5
 * @link      https://github.com/hiqdev/yii2-mfa
6
 * @package   yii2-mfa
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\yii2\mfa\behaviors;
12
13
use Yii;
14
use yii\base\Event;
15
use yii\web\User;
16
17
class ValidateMfaBehavior extends \yii\base\Behavior
18
{
19
    public function events()
20
    {
21
        return [
22
            User::EVENT_BEFORE_LOGIN => 'beforeLogin',
23
        ];
24
    }
25
26
    public function beforeLogin(Event $event)
27
    {
28
        $module = Yii::$app->getModule('mfa');
29
        $identity = $event->identity;
30
        $module->setHalfUser($identity);
31
        $module->validateIps($identity);
32
        $module->validateTotp($identity);
33
    }
34
}
35