aklim / yii2-check-login-attempts
本包最新版本(v1.1.4)没有提供许可证信息。
多次失败后禁用登录。
v1.1.4
2020-06-10 14:52 UTC
Requires
- yiisoft/yii2: *
README
这是一个登录尝试检查器,由 https://github.com/giannisdag/yii2-check-login-attempts 分支而来
基于 https://github.com/ethercreative/yii2-login-attempts-behavior
安装
安装此扩展的首选方法是使用composer。运行以下命令之一:
composer require aklim/yii2-check-login-attempts
或者将以下内容添加到您的composer.json文件的require部分:
"aklim/yii2-check-login-attempts": "*"
。
使用方法
运行以下迁移
php yii migrate --migrationPath="@vendor/aklim/yii2-check-login-attempts/src/migrations" --interactive=0
将行为添加到您的登录模型中
public function behaviors() { $behaviors = parent::behaviors(); $behaviors[] = [ 'class' => '\aklim\yii2CheckLoginAttempts\behaviors\LoginAttemptBehavior', // Amount of attempts in the given time period 'attempts' => 3, // the duration, in seconds, for a regular failure to be stored for // resets on new failure 'duration' => 300, // the duration, in seconds, to disable login after exceeding `attemps` 'disableDuration' => 900, // the attribute used as the key in the database // and add errors to 'usernameAttribute' => 'username', // the attribute to check for errors 'passwordAttribute' => 'password', // the validation message to return to `usernameAttribute` 'message' => Yii::t('app', 'Login disabled'), ]; return $behaviors; }