Skip to content

crestoff/yii2badlogin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yii2 Bad Login Behavior

Store login failures, and disable after multiple failures.

Installation

The preferred way to install this extension is through composer.

Either run

composer require crestoff/yii2badlogin

or add

"crestoff/yii2badlogin" : "*"

to the require section of your composer.json file.

Usage

Run the following migration

php yii migrate --migrationPath="vendor/crestoff/yii2badlogin/src/migrations" --interactive=0

Add the behavior to your login model.

public function behaviors()
{
    $behaviors = parent::behaviors();

    $behaviors[] = [
        'class' => '\crestoff\badlogin\LoginAttemptBehavior',

        'attempts' => 3,
        'duration' => 300,
        'durationUnit' => 'second',
        'disableDuration' => 900,
        'clearOnHandle' => true,
        'clearDuration' => 30,
        'clearDurationUnit' => 'day',
        'disableDurationUnit' => 'second',
        'usernameAttribute' => 'email',
        'passwordAttribute' => 'password',
        'message' => 'Login is disabled',
    ];

    return $behaviors;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%