Browse Source

登录验证码2

master
wanghongjun 4 weeks ago
parent
commit
780367c160
  1. 16
      app/controller/admin/Login.php

16
app/controller/admin/Login.php

@ -96,8 +96,12 @@ class Login extends Base {
return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户已被封禁,请联系管理员');
}
} else {
$this->setFailKey($username);
return $this->buildFailed(ReturnCode::LOGIN_ERROR, '用户名密码不正确');
$count = $this->setFailKey($username);
return $this->buildFailed(
ReturnCode::LOGIN_ERROR,
'用户名密码不正确',
['need_captcha' => $count >= $this->captchaThreshold]
);
}
$userInfo['access'] = $this->getAccess($userInfo['id']);
$userInfo['menu'] = $this->getAccessMenuData($userInfo['id']);
@ -221,15 +225,13 @@ class Login extends Base {
]);
}
protected function captchaCheck($username, $captchaToken, $captchaInput)
{
}
protected function setFailKey($username)
{
$failKey = "login:fail:{$username}";
$failCount = (int) Cache::get($failKey, 0);
Cache::set($failKey, $failCount + 1, $this->lockMinutes * 60);
$failCount += 1;
Cache::set($failKey, $failCount, $this->lockMinutes * 60);
return $failCount;
}
/**

Loading…
Cancel
Save