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:
parent
9b37570a78
commit
a360ce0f83
@ -206,9 +206,6 @@ class User extends Service
|
|||||||
|
|
||||||
if (!empty($post['vip_expiry_time'])) {
|
if (!empty($post['vip_expiry_time'])) {
|
||||||
$data['vip_expiry_time'] = $validator->checkVipExpiryTime($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'])) {
|
if (isset($post['locked'])) {
|
||||||
@ -217,9 +214,6 @@ class User extends Service
|
|||||||
|
|
||||||
if (!empty($post['lock_expiry_time'])) {
|
if (!empty($post['lock_expiry_time'])) {
|
||||||
$data['lock_expiry_time'] = $validator->checkLockExpiryTime($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;
|
$oldAdminRole = $user->admin_role;
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
xmSelect.render({
|
xmSelect.render({
|
||||||
el: '#xm-tag-ids',
|
el: '#xm-tag-ids',
|
||||||
name: 'xm_tag_ids',
|
name: 'xm_tag_ids',
|
||||||
max: 3,
|
max: 5,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
filterMethod: function (val, item, index, prop) {
|
filterMethod: function (val, item, index, prop) {
|
||||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
xmSelect.render({
|
xmSelect.render({
|
||||||
el: '#xm-tag-ids',
|
el: '#xm-tag-ids',
|
||||||
name: 'xm_tag_ids',
|
name: 'xm_tag_ids',
|
||||||
max: 3,
|
max: 5,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
filterMethod: function (val, item, index, prop) {
|
filterMethod: function (val, item, index, prop) {
|
||||||
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
return item.name.toLowerCase().indexOf(val.toLowerCase()) !== -1;
|
||||||
|
@ -16,7 +16,7 @@ class AppInfo
|
|||||||
|
|
||||||
protected $link = 'https://www.koogua.com';
|
protected $link = 'https://www.koogua.com';
|
||||||
|
|
||||||
protected $version = '1.7.2';
|
protected $version = '1.7.3';
|
||||||
|
|
||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@ class UserSession extends Repository
|
|||||||
{
|
{
|
||||||
return UserSessionModel::query()
|
return UserSessionModel::query()
|
||||||
->where('user_id = :user_id:', ['user_id' => $userId])
|
->where('user_id = :user_id:', ['user_id' => $userId])
|
||||||
|
->andWhere('expire_time < :time:', ['time' => time()])
|
||||||
->andWhere('deleted = 0')
|
->andWhere('deleted = 0')
|
||||||
->execute();
|
->execute();
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ class UserToken extends Repository
|
|||||||
{
|
{
|
||||||
return UserTokenModel::query()
|
return UserTokenModel::query()
|
||||||
->where('user_id = :user_id:', ['user_id' => $userId])
|
->where('user_id = :user_id:', ['user_id' => $userId])
|
||||||
|
->andWhere('expire_time < :time:', ['time' => time()])
|
||||||
|
->andWhere('deleted = 0')
|
||||||
->execute();
|
->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,6 @@ class Api extends AuthService
|
|||||||
$cache = $this->getCache();
|
$cache = $this->getCache();
|
||||||
|
|
||||||
foreach ($userTokens as $record) {
|
foreach ($userTokens as $record) {
|
||||||
$record->delete();
|
|
||||||
$key = $this->getTokenCacheKey($record->token);
|
$key = $this->getTokenCacheKey($record->token);
|
||||||
$cache->delete($key);
|
$cache->delete($key);
|
||||||
}
|
}
|
||||||
@ -111,7 +110,6 @@ class Api extends AuthService
|
|||||||
|
|
||||||
foreach ($userTokens as $record) {
|
foreach ($userTokens as $record) {
|
||||||
if ($record->client_type == $clientType) {
|
if ($record->client_type == $clientType) {
|
||||||
$record->delete();
|
|
||||||
$key = $this->getTokenCacheKey($record->token);
|
$key = $this->getTokenCacheKey($record->token);
|
||||||
$cache->delete($key);
|
$cache->delete($key);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@ class Home extends AuthService
|
|||||||
if ($records->count() == 0) return;
|
if ($records->count() == 0) return;
|
||||||
|
|
||||||
foreach ($records as $record) {
|
foreach ($records as $record) {
|
||||||
$record->delete();
|
|
||||||
$key = $this->getSessionCacheKey($record->session_id);
|
$key = $this->getSessionCacheKey($record->session_id);
|
||||||
$cache->delete($key);
|
$cache->delete($key);
|
||||||
}
|
}
|
||||||
|
@ -184,11 +184,18 @@ class Account extends Validator
|
|||||||
|
|
||||||
public function checkIfAllowLogin(UserModel $user)
|
public function checkIfAllowLogin(UserModel $user)
|
||||||
{
|
{
|
||||||
$case1 = $user->locked == 1;
|
$locked = false;
|
||||||
$case2 = $user->lock_expiry_time > time();
|
|
||||||
|
|
||||||
if ($case1 && $case2) {
|
if ($user->locked == 1) {
|
||||||
throw new ForbiddenException('account.locked');
|
if ($user->lock_expiry_time == 0) {
|
||||||
|
$locked = true;
|
||||||
|
} elseif ($user->lock_expiry_time > time()) {
|
||||||
|
$locked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($locked) {
|
||||||
|
throw new BadRequestException('account.locked');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user