diff --git a/app/Auth/NexusWebGuard.php b/app/Auth/NexusWebGuard.php index cbd399bc..9eaa940a 100644 --- a/app/Auth/NexusWebGuard.php +++ b/app/Auth/NexusWebGuard.php @@ -74,11 +74,17 @@ class NexusWebGuard implements StatefulGuard return false; } $user = $this->provider->retrieveById($id); - if ($user) { + if (!$user) { + return false; + } + try { + $user->checkIsNormal(); $this->user = $user; return true; + } catch (\Throwable $e) { + do_log($e->getMessage()); + return false; } - return false; } public function logout() diff --git a/app/Filament/PageListSingle.php b/app/Filament/PageListSingle.php index d3d94488..ca77e367 100644 --- a/app/Filament/PageListSingle.php +++ b/app/Filament/PageListSingle.php @@ -16,10 +16,8 @@ class PageListSingle extends ManageRecords return Layout::AboveContent; } - protected function getTableRecordUrlUsing(): ?Closure + protected function getTableRecordActionUsing(): ?Closure { - return function (Model $record): ?string { - return null; - }; + return null; } } diff --git a/app/Filament/Resources/Oauth/AccessTokenResource.php b/app/Filament/Resources/Oauth/AccessTokenResource.php new file mode 100644 index 00000000..a57d3877 --- /dev/null +++ b/app/Filament/Resources/Oauth/AccessTokenResource.php @@ -0,0 +1,76 @@ +schema([ + // + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id')->searchable(), + Tables\Columns\TextColumn::make('user.username') + ->label(__('label.username')) + ->formatStateUsing(fn ($record) => username_for_admin($record->user_id)), + Tables\Columns\TextColumn::make('client.name') + ->label(__('oauth.client')), + Tables\Columns\TextColumn::make('expires_at') + ->label(__('label.expire_at')) + + ]) + ->filters([ + // + ]) + ->actions([ +// Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ManageAccessTokens::route('/'), + ]; + } +} diff --git a/app/Filament/Resources/Oauth/AccessTokenResource/Pages/ManageAccessTokens.php b/app/Filament/Resources/Oauth/AccessTokenResource/Pages/ManageAccessTokens.php new file mode 100644 index 00000000..babbb721 --- /dev/null +++ b/app/Filament/Resources/Oauth/AccessTokenResource/Pages/ManageAccessTokens.php @@ -0,0 +1,20 @@ +schema([ + // + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id'), + Tables\Columns\TextColumn::make('user.username') + ->label(__('label.username')) + ->formatStateUsing(fn ($record) => username_for_admin($record->user_id)), + Tables\Columns\TextColumn::make('client.name') + ->label(__('oauth.client')), + Tables\Columns\TextColumn::make('expires_at') + ->label(__('label.expire_at')) + ]) + ->filters([ + // + ]) + ->actions([ +// Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ManageAuthCodes::route('/'), + ]; + } +} diff --git a/app/Filament/Resources/Oauth/AuthCodeResource/Pages/ManageAuthCodes.php b/app/Filament/Resources/Oauth/AuthCodeResource/Pages/ManageAuthCodes.php new file mode 100644 index 00000000..72144eb4 --- /dev/null +++ b/app/Filament/Resources/Oauth/AuthCodeResource/Pages/ManageAuthCodes.php @@ -0,0 +1,20 @@ +schema([ + Forms\Components\TextInput::make('name')->label(__('label.name')), + Forms\Components\TextInput::make('redirect')->label(__('oauth.redirect')), + + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id'), + Tables\Columns\TextColumn::make('name')->label(__('label.name')), + Tables\Columns\TextColumn::make('secret')->label(__('oauth.secret')), + Tables\Columns\TextColumn::make('redirect')->label(__('oauth.redirect')), + + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ManageClients::route('/'), + ]; + } +} diff --git a/app/Filament/Resources/Oauth/ClientResource/Pages/ManageClients.php b/app/Filament/Resources/Oauth/ClientResource/Pages/ManageClients.php new file mode 100644 index 00000000..97083f5f --- /dev/null +++ b/app/Filament/Resources/Oauth/ClientResource/Pages/ManageClients.php @@ -0,0 +1,20 @@ +schema([ + // + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('id') + ->label(__('oauth.refresh_token')) + ->searchable() + , + Tables\Columns\TextColumn::make('access_token_id') + ->label(__('oauth.access_token')) + ->searchable() + , + Tables\Columns\TextColumn::make('expires_at') + ->label(__('label.expire_at')) + ]) + ->filters([ + // + ]) + ->actions([ +// Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make(), + ]) + ->bulkActions([ + Tables\Actions\DeleteBulkAction::make(), + ]); + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ManageRefreshTokens::route('/'), + ]; + } +} diff --git a/app/Filament/Resources/Oauth/RefreshTokenResource/Pages/ManageRefreshTokens.php b/app/Filament/Resources/Oauth/RefreshTokenResource/Pages/ManageRefreshTokens.php new file mode 100644 index 00000000..22bde447 --- /dev/null +++ b/app/Filament/Resources/Oauth/RefreshTokenResource/Pages/ManageRefreshTokens.php @@ -0,0 +1,20 @@ + 'Bonus logs', 'torrent_buy_log' => 'Torrent buy logs', 'attendance_log' => 'Attendance logs', + 'oauth_client' => 'Client', + 'oauth_access_token' => 'Access tokens', + 'oauth_auth_code' => 'Auth codes', + 'oauth_refresh_token' => 'Refresh tokens', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/en/oauth.php b/resources/lang/en/oauth.php new file mode 100644 index 00000000..3e722458 --- /dev/null +++ b/resources/lang/en/oauth.php @@ -0,0 +1,9 @@ + 'Client', + 'redirect' => 'Redirect URL', + 'secret' => 'Secret', + 'revoked' => 'Valid', + 'access_token' => 'Access token', + 'refresh_token' => 'Refresh token', +]; diff --git a/resources/lang/zh_CN/admin.php b/resources/lang/zh_CN/admin.php index 2389c818..7d4f9b83 100644 --- a/resources/lang/zh_CN/admin.php +++ b/resources/lang/zh_CN/admin.php @@ -36,6 +36,10 @@ return [ 'bonus_log' => '魔力记录', 'torrent_buy_log' => '种子购买', 'attendance_log' => '签到记录', + 'oauth_client' => '客户端', + 'oauth_access_token' => '访问令牌', + 'oauth_auth_code' => '授权码', + 'oauth_refresh_token' => '刷新令牌', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/zh_CN/oauth.php b/resources/lang/zh_CN/oauth.php new file mode 100644 index 00000000..810b3f27 --- /dev/null +++ b/resources/lang/zh_CN/oauth.php @@ -0,0 +1,9 @@ + '客户端', + 'redirect' => '回调地址', + 'secret' => '密钥', + 'revoked' => '有效', + 'access_token' => '访问令牌', + 'refresh_token' => '刷新令牌', +]; diff --git a/resources/lang/zh_TW/admin.php b/resources/lang/zh_TW/admin.php index 18b7d534..3d67d0cb 100644 --- a/resources/lang/zh_TW/admin.php +++ b/resources/lang/zh_TW/admin.php @@ -38,6 +38,10 @@ return [ 'bonus_log' => '魔力記錄', 'torrent_buy_log' => '種子購買', 'attendance_log' => '簽到記錄', + 'oauth_client' => '客戶端', + 'oauth_access_token' => '訪問令牌', + 'oauth_auth_code' => '授權碼', + 'oauth_refresh_token' => '刷新令牌', ], 'resources' => [ 'agent_allow' => [ diff --git a/resources/lang/zh_TW/oauth.php b/resources/lang/zh_TW/oauth.php new file mode 100644 index 00000000..38e424a8 --- /dev/null +++ b/resources/lang/zh_TW/oauth.php @@ -0,0 +1,9 @@ + '客戶端', + 'redirect' => '回調地址', + 'secret' => '密鑰', + 'revoked' => '有效', + 'access_token' => '訪問令牌', + 'refresh_token' => '刷新令牌', +];