diff --git a/app/Auth/NexusWebGuard.php b/app/Auth/NexusWebGuard.php index b036d080..3280e574 100644 --- a/app/Auth/NexusWebGuard.php +++ b/app/Auth/NexusWebGuard.php @@ -1,6 +1,7 @@ request->cookie(); if ($this->validate($credentials)) { + /** + * @var User $user + */ $user = $this->provider->retrieveByCredentials($credentials); if (empty($user)) { return null; } if ($this->provider->validateCredentials($user, $credentials)) { - if ($user->checkIsNormal()) { - return $this->user = $user; - } + $user->checkIsNormal(); + return $this->user = $user; } } } diff --git a/app/Filament/Resources/System/PluginStoreResource.php b/app/Filament/Resources/System/PluginStoreResource.php index 7a105f59..0b01e3a9 100644 --- a/app/Filament/Resources/System/PluginStoreResource.php +++ b/app/Filament/Resources/System/PluginStoreResource.php @@ -100,7 +100,7 @@ class PluginStoreResource extends Resource } return nexus_trans("plugin.actions.install"); }) - ->modalHeading(fn (PluginStore $record) => sprintf("%s: %s", nexus_trans("plugin.actions.install_or_update") ,$record->title)) + ->modalHeading(fn (PluginStore $record) => sprintf("%s: %s", nexus_trans("plugin.actions.install_or_update"), data_get($record, self::getColumnLabelKey("title")))) ->modalContent(function (PluginStore $record) { $infolist = new Infolist(); $infolist->record = $record; diff --git a/app/Models/User.php b/app/Models/User.php index 51e336db..870c7f60 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Exceptions\NexusException; use App\Http\Middleware\Locale; use App\Repositories\ExamRepository; use Carbon\Carbon; @@ -277,12 +278,11 @@ class User extends Authenticatable implements FilamentUser, HasName public function checkIsNormal(array $fields = ['status', 'enabled']): bool { if (in_array('status', $fields) && $this->getAttribute('status') != self::STATUS_CONFIRMED) { - throw new \InvalidArgumentException(sprintf('User: %s is not confirmed.', $this->id)); + throw new NexusException(nexus_trans("user.user_is_not_confirmed", ['user_id' => $this->id, 'username' => $this->username])); } if (in_array('enabled', $fields) && $this->getAttribute('enabled') != self::ENABLED_YES) { - throw new \InvalidArgumentException(sprintf('User: %s is not enabled.', $this->id)); + throw new NexusException(nexus_trans("user.user_is_disabled", ['user_id' => $this->id, 'username' => $this->username])); } - return true; } diff --git a/resources/lang/zh_CN/user.php b/resources/lang/zh_CN/user.php index e69dc3c8..2ba204bf 100644 --- a/resources/lang/zh_CN/user.php +++ b/resources/lang/zh_CN/user.php @@ -109,4 +109,6 @@ return [ 'msg_invited_user_has_registered' => "你邀请的用户已注册", 'msg_user_you_invited' => "你邀请的用户 ", 'msg_has_registered' => " 刚刚已注册。", + 'user_is_disabled' => '用户::username(ID: :user_id) 已被封禁', + 'user_is_not_confirmed' => '用户::username(ID: :user_id) 未确认', ];