优化数据归属问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user