- - 注册设置
+ - 基本设置
- QQ登录
- 微信登录
- 微博登录
diff --git a/app/Http/Admin/Views/setting/oauth_local.volt b/app/Http/Admin/Views/setting/oauth_local.volt
index abf2b312..00967b3b 100644
--- a/app/Http/Admin/Views/setting/oauth_local.volt
+++ b/app/Http/Admin/Views/setting/oauth_local.volt
@@ -16,13 +16,13 @@
diff --git a/app/Library/Cache/Backend/Redis.php b/app/Library/Cache/Backend/Redis.php
index d9951ea7..3d9d7fab 100644
--- a/app/Library/Cache/Backend/Redis.php
+++ b/app/Library/Cache/Backend/Redis.php
@@ -161,7 +161,7 @@ class Redis extends \Phalcon\Cache\Backend\Redis
$redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY);
- $it = null;
+ $it = 0;
while ($keys = $redis->scan($it, $pattern)) {
if (count($result) > $limit) break;
@@ -191,6 +191,35 @@ class Redis extends \Phalcon\Cache\Backend\Redis
return (bool)$redis->exists($lastKey);
}
+ /**
+ * @param string $keyName
+ * @return bool
+ */
+ public function expire($keyName = null, $lifetime = null): bool
+ {
+ $redis = $this->getRedis();
+
+ /**
+ * @var FrontendInterface $frontend
+ */
+ $frontend = $this->_frontend;
+
+ if ($keyName === null) {
+ $lastKey = $this->_lastKey;
+ } else {
+ $lastKey = $this->getKeyName($keyName);
+ }
+
+ if ($lifetime === null) {
+ $tmp = $this->_lastLifetime;
+ $ttl = $tmp ?: $frontend->getLifetime();
+ } else {
+ $ttl = $lifetime;
+ }
+
+ return $redis->expire($lastKey, $ttl);
+ }
+
/**
* @param string $keyName
* @return int|bool
diff --git a/app/Repos/UserSession.php b/app/Repos/UserSession.php
index 26f1b542..6b438edf 100644
--- a/app/Repos/UserSession.php
+++ b/app/Repos/UserSession.php
@@ -26,19 +26,4 @@ class UserSession extends Repository
->execute();
}
- /**
- * @param int $userId
- * @param int $minutes
- * @return ResultsetInterface|Resultset|UserSessionModel[]
- */
- public function findUserRecentSessions($userId, $minutes = 10)
- {
- $createTime = time() - $minutes * 60;
-
- return UserSessionModel::query()
- ->where('user_id = :user_id:', ['user_id' => $userId])
- ->andWhere('create_time > :create_time:', ['create_time' => $createTime])
- ->execute();
- }
-
}
diff --git a/app/Repos/UserToken.php b/app/Repos/UserToken.php
index 056d8358..c8cc17e6 100644
--- a/app/Repos/UserToken.php
+++ b/app/Repos/UserToken.php
@@ -25,19 +25,4 @@ class UserToken extends Repository
->execute();
}
- /**
- * @param int $userId
- * @param int $minutes
- * @return ResultsetInterface|Resultset|UserTokenModel[]
- */
- public function findUserRecentTokens($userId, $minutes = 10)
- {
- $createTime = time() - $minutes * 60;
-
- return UserTokenModel::query()
- ->where('user_id = :user_id:', ['user_id' => $userId])
- ->andWhere('create_time > :create_time:', ['create_time' => $createTime])
- ->execute();
- }
-
}
diff --git a/app/Services/Auth/Home.php b/app/Services/Auth/Home.php
index 9db3e691..15203913 100644
--- a/app/Services/Auth/Home.php
+++ b/app/Services/Auth/Home.php
@@ -54,11 +54,6 @@ class Home extends AuthService
return $authInfo ?: null;
}
- public function getAuthKey()
- {
- return 'home_auth_info';
- }
-
public function logoutClients($userId)
{
$cache = $this->getCache();
@@ -101,4 +96,9 @@ class Home extends AuthService
return "_PHCR_SESSION_:{$sessionId}";
}
+ protected function getAuthKey()
+ {
+ return 'home_auth_info';
+ }
+
}
diff --git a/app/Validators/Account.php b/app/Validators/Account.php
index 4725f2c2..2b8f1389 100644
--- a/app/Validators/Account.php
+++ b/app/Validators/Account.php
@@ -12,12 +12,9 @@ use App\Exceptions\Forbidden as ForbiddenException;
use App\Library\Utils\Password as PasswordUtil;
use App\Library\Validators\Common as CommonValidator;
use App\Models\Account as AccountModel;
-use App\Models\Client as ClientModel;
use App\Models\User as UserModel;
use App\Repos\Account as AccountRepo;
use App\Repos\User as UserRepo;
-use App\Repos\UserSession as UserSessionRepo;
-use App\Repos\UserToken as UserTokenRepo;
use App\Traits\Client as ClientTrait;
class Account extends Validator
@@ -193,34 +190,6 @@ class Account extends Validator
if ($case1 && $case2) {
throw new ForbiddenException('account.locked');
}
-
- $this->checkFloodLogin($user->id);
- }
-
- public function checkFloodLogin($userId)
- {
- $clientIp = $this->getClientIp();
- $clientType = $this->getClientType();
-
- if ($clientType == ClientModel::TYPE_PC) {
- $repo = new UserSessionRepo();
- $records = $repo->findUserRecentSessions($userId, 10);
- } else {
- $repo = new UserTokenRepo();
- $records = $repo->findUserRecentTokens($userId, 10);
- }
-
- if ($records->count() == 0) return;
-
- $clientIps = array_column($records->toArray(), 'client_ip');
-
- $countValues = array_count_values($clientIps);
-
- foreach ($countValues as $ip => $count) {
- if ($clientIp == $ip && $count > 4) {
- throw new ForbiddenException('account.flood_login');
- }
- }
}
}
diff --git a/config/errors.php b/config/errors.php
index 7b94647c..7a979b6d 100644
--- a/config/errors.php
+++ b/config/errors.php
@@ -47,7 +47,6 @@ $error['captcha.invalid_code'] = '无效的验证码';
*/
$error['account.not_found'] = '账号不存在';
$error['account.locked'] = '账号被锁定,无法登录';
-$error['account.flood_login'] = '帐号泛滥登录';
$error['account.login_pwd_incorrect'] = '登录密码不正确';
$error['account.invalid_login_name'] = '无效的登录名';
$error['account.invalid_email'] = '无效的电子邮箱';
diff --git a/public/static/home/js/captcha.verify.js b/public/static/home/js/captcha.verify.js
index afa9f7b1..289526c1 100644
--- a/public/static/home/js/captcha.verify.js
+++ b/public/static/home/js/captcha.verify.js
@@ -11,7 +11,7 @@ layui.use(['jquery', 'layer', 'helper'], function () {
var url = '/verify/captcha?type=all&account=' + $account.val();
layer.open({
type: 2,
- title: '获取验证码',
+ title: '验证码',
area: ['500px', '250px'],
content: [url, 'no'],
});