1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-08-03 13:02:55 +08:00

1.优化findUserActiveSessions

2.优化findUserActiveTokens
3.修改文章和提问可用tag数量
4.优化用户锁定相关
This commit is contained in:
xiaochong0302 2024-09-13 18:52:39 +08:00
parent 9b37570a78
commit a360ce0f83
9 changed files with 17 additions and 16 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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');
}
}