From a360ce0f83c24b218fd5ccf7cf41bd8fe1ad70f8 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Fri, 13 Sep 2024 18:52:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96findUserActiveSessions=202.?= =?UTF-8?q?=E4=BC=98=E5=8C=96findUserActiveTokens=203.=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=92=8C=E6=8F=90=E9=97=AE=E5=8F=AF=E7=94=A8?= =?UTF-8?q?tag=E6=95=B0=E9=87=8F=204.=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=94=81=E5=AE=9A=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Admin/Services/User.php | 6 ------ app/Http/Admin/Views/article/edit.volt | 2 +- app/Http/Admin/Views/question/edit.volt | 2 +- app/Library/AppInfo.php | 2 +- app/Repos/UserSession.php | 1 + app/Repos/UserToken.php | 2 ++ app/Services/Auth/Api.php | 2 -- app/Services/Auth/Home.php | 1 - app/Validators/Account.php | 15 +++++++++++---- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/Http/Admin/Services/User.php b/app/Http/Admin/Services/User.php index 46d87a07..83037a04 100644 --- a/app/Http/Admin/Services/User.php +++ b/app/Http/Admin/Services/User.php @@ -206,9 +206,6 @@ class User extends Service if (!empty($post['vip_expiry_time'])) { $data['vip_expiry_time'] = $validator->checkVipExpiryTime($post['vip_expiry_time']); - if ($data['vip_expiry_time'] < time()) { - $data['vip'] = 0; - } } if (isset($post['locked'])) { @@ -217,9 +214,6 @@ class User extends Service if (!empty($post['lock_expiry_time'])) { $data['lock_expiry_time'] = $validator->checkLockExpiryTime($post['lock_expiry_time']); - if ($data['lock_expiry_time'] < time()) { - $data['locked'] = 0; - } } $oldAdminRole = $user->admin_role; diff --git a/app/Http/Admin/Views/article/edit.volt b/app/Http/Admin/Views/article/edit.volt index dc1c11c5..db2ca7aa 100644 --- a/app/Http/Admin/Views/article/edit.volt +++ b/app/Http/Admin/Views/article/edit.volt @@ -47,7 +47,7 @@ xmSelect.render({ el: '#xm-tag-ids', name: 'xm_tag_ids', - max: 3, + max: 5, filterable: true, filterMethod: function (val, item, index, prop) { return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1; diff --git a/app/Http/Admin/Views/question/edit.volt b/app/Http/Admin/Views/question/edit.volt index 991ae139..4ad70bf6 100644 --- a/app/Http/Admin/Views/question/edit.volt +++ b/app/Http/Admin/Views/question/edit.volt @@ -46,7 +46,7 @@ xmSelect.render({ el: '#xm-tag-ids', name: 'xm_tag_ids', - max: 3, + max: 5, filterable: true, filterMethod: function (val, item, index, prop) { return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1; diff --git a/app/Library/AppInfo.php b/app/Library/AppInfo.php index 7207b968..0939d2d8 100644 --- a/app/Library/AppInfo.php +++ b/app/Library/AppInfo.php @@ -16,7 +16,7 @@ class AppInfo protected $link = 'https://www.koogua.com'; - protected $version = '1.7.2'; + protected $version = '1.7.3'; public function __get($name) { diff --git a/app/Repos/UserSession.php b/app/Repos/UserSession.php index 6b438edf..3ac6add0 100644 --- a/app/Repos/UserSession.php +++ b/app/Repos/UserSession.php @@ -22,6 +22,7 @@ class UserSession extends Repository { return UserSessionModel::query() ->where('user_id = :user_id:', ['user_id' => $userId]) + ->andWhere('expire_time < :time:', ['time' => time()]) ->andWhere('deleted = 0') ->execute(); } diff --git a/app/Repos/UserToken.php b/app/Repos/UserToken.php index c8cc17e6..9152a63b 100644 --- a/app/Repos/UserToken.php +++ b/app/Repos/UserToken.php @@ -22,6 +22,8 @@ class UserToken extends Repository { return UserTokenModel::query() ->where('user_id = :user_id:', ['user_id' => $userId]) + ->andWhere('expire_time < :time:', ['time' => time()]) + ->andWhere('deleted = 0') ->execute(); } diff --git a/app/Services/Auth/Api.php b/app/Services/Auth/Api.php index 71084950..f854094f 100644 --- a/app/Services/Auth/Api.php +++ b/app/Services/Auth/Api.php @@ -95,7 +95,6 @@ class Api extends AuthService $cache = $this->getCache(); foreach ($userTokens as $record) { - $record->delete(); $key = $this->getTokenCacheKey($record->token); $cache->delete($key); } @@ -111,7 +110,6 @@ class Api extends AuthService foreach ($userTokens as $record) { if ($record->client_type == $clientType) { - $record->delete(); $key = $this->getTokenCacheKey($record->token); $cache->delete($key); } diff --git a/app/Services/Auth/Home.php b/app/Services/Auth/Home.php index 15203913..a5a92a34 100644 --- a/app/Services/Auth/Home.php +++ b/app/Services/Auth/Home.php @@ -65,7 +65,6 @@ class Home extends AuthService if ($records->count() == 0) return; foreach ($records as $record) { - $record->delete(); $key = $this->getSessionCacheKey($record->session_id); $cache->delete($key); } diff --git a/app/Validators/Account.php b/app/Validators/Account.php index 2b8f1389..f3ff1f61 100644 --- a/app/Validators/Account.php +++ b/app/Validators/Account.php @@ -184,11 +184,18 @@ class Account extends Validator public function checkIfAllowLogin(UserModel $user) { - $case1 = $user->locked == 1; - $case2 = $user->lock_expiry_time > time(); + $locked = false; - if ($case1 && $case2) { - throw new ForbiddenException('account.locked'); + if ($user->locked == 1) { + if ($user->lock_expiry_time == 0) { + $locked = true; + } elseif ($user->lock_expiry_time > time()) { + $locked = true; + } + } + + if ($locked) { + throw new BadRequestException('account.locked'); } }