优化数据归属问题

This commit is contained in:
2026-04-23 15:08:37 +08:00
parent 378be9909d
commit 0373234750
29 changed files with 1993 additions and 75 deletions

View File

@@ -80,6 +80,11 @@ class Auth extends \ba\Auth
$this->setError('Account disabled');
return false;
}
$channelId = intval($this->model->channel_id ?? 0);
if ($channelId > 0 && !$this->isChannelEnabled($channelId)) {
$this->setError('Channel disabled');
return false;
}
$this->token = $token;
$this->loginEd = true;
return true;
@@ -136,6 +141,11 @@ class Auth extends \ba\Auth
'remark' => User::formatLoginRemark($time, $ip),
];
$data = array_merge(compact('username', 'password', 'phone', 'email'), $data, $extend);
$channelIdForRegister = isset($data['channel_id']) ? intval($data['channel_id']) : 0;
if ($channelIdForRegister > 0 && !$this->isChannelEnabled($channelIdForRegister)) {
$this->setError('Channel disabled');
return false;
}
Db::startTrans();
try {
@@ -178,6 +188,11 @@ class Auth extends \ba\Auth
$this->setError('Account disabled');
return false;
}
$channelId = intval($this->model->channel_id ?? 0);
if ($channelId > 0 && !$this->isChannelEnabled($channelId)) {
$this->setError('Channel disabled');
return false;
}
$userLoginRetry = config('buildadmin.user_login_retry');
if ($userLoginRetry && $this->model->last_login_time) {
@@ -382,4 +397,13 @@ class Auth extends \ba\Auth
$this->setKeepTime((int)config('buildadmin.user_token_keep_time', 86400));
return true;
}
private function isChannelEnabled(int $channelId): bool
{
$status = Db::name('channel')->where('id', $channelId)->value('status');
if ($status === null || $status === '') {
return false;
}
return intval($status) === 1;
}
}