Accept Merge Request #110: (feature/zy -> develop)
Merge Request: feature: 登录校验 Created By: @zhuyu Accepted By: @zhuyu URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/110?initial=true
This commit is contained in:
commit
d4d90ae5de
|
|
@ -47,6 +47,13 @@ class Auth extends \fast\Auth
|
|||
$this->setError('Admin is forbidden');
|
||||
return false;
|
||||
}
|
||||
|
||||
//ip白名单校验
|
||||
if (!$this->allowIpCheck($admin)) {
|
||||
$this->setError('登录失败:您的IP地址不在公司允许范围内!');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Config::get('fastadmin.login_failure_retry') && $admin->loginfailure >= 10 && time() - $admin->updatetime < 86400) {
|
||||
$this->setError('Please try again after 1 day');
|
||||
return false;
|
||||
|
|
@ -68,6 +75,29 @@ class Auth extends \fast\Auth
|
|||
return true;
|
||||
}
|
||||
|
||||
public function allowIpCheck($admin){
|
||||
|
||||
if (in_array('*', $this->getRuleIds($admin->id))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$allowIpCheck = Config::get('site.allowip_check');
|
||||
if ($allowIpCheck != 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$allowIp = Config::get('site.allowip');
|
||||
$allowIp = explode("\r\n", $allowIp);
|
||||
if (empty($allowIp)) {
|
||||
return false;
|
||||
}
|
||||
$ip = request()->ip();
|
||||
if (!in_array($ip, $allowIp)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user