mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
Merge remote-tracking branch 'refs/remotes/origin/php8' into php8
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -50,7 +50,8 @@ class Handler extends ExceptionHandler
|
||||
}
|
||||
});
|
||||
$this->renderable(function (PassportAuthenticationException $e) {
|
||||
return response()->redirectTo(getSchemeAndHttpHost() . "/login.php");
|
||||
$request = request();
|
||||
return response()->redirectTo(sprintf("%s/login.php?returnto=%s", $request->getSchemeAndHttpHost(), urlencode($request->fullUrl())));
|
||||
});
|
||||
|
||||
//Other Only handle in json request
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
76
app/Filament/Resources/Oauth/AccessTokenResource.php
Normal file
76
app/Filament/Resources/Oauth/AccessTokenResource.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth;
|
||||
|
||||
use App\Filament\Resources\Oauth\AccessTokenResource\Pages;
|
||||
use App\Filament\Resources\Oauth\AccessTokenResource\RelationManagers;
|
||||
use Laravel\Passport\Token;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class AccessTokenResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Token::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
|
||||
protected static ?string $navigationGroup = 'Oauth';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.oauth_access_token');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth\AccessTokenResource\Pages;
|
||||
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\Oauth\AccessTokenResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageAccessTokens extends PageListSingle
|
||||
{
|
||||
protected static string $resource = AccessTokenResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
75
app/Filament/Resources/Oauth/AuthCodeResource.php
Normal file
75
app/Filament/Resources/Oauth/AuthCodeResource.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth;
|
||||
|
||||
use App\Filament\Resources\Oauth\AuthCodeResource\Pages;
|
||||
use App\Filament\Resources\Oauth\AuthCodeResource\RelationManagers;
|
||||
use Laravel\Passport\AuthCode;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class AuthCodeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AuthCode::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
|
||||
protected static ?string $navigationGroup = 'Oauth';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.oauth_auth_code');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth\AuthCodeResource\Pages;
|
||||
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\Oauth\AuthCodeResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageAuthCodes extends PageListSingle
|
||||
{
|
||||
protected static string $resource = AuthCodeResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
75
app/Filament/Resources/Oauth/ClientResource.php
Normal file
75
app/Filament/Resources/Oauth/ClientResource.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth;
|
||||
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\Oauth\ClientResource\Pages;
|
||||
use App\Filament\Resources\Oauth\ClientResource\RelationManagers;
|
||||
use Laravel\Passport\Client;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class ClientResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Client::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
|
||||
protected static ?string $navigationGroup = 'Oauth';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.oauth_client');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth\ClientResource\Pages;
|
||||
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\Oauth\ClientResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageClients extends PageListSingle
|
||||
{
|
||||
protected static string $resource = ClientResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
77
app/Filament/Resources/Oauth/RefreshTokenResource.php
Normal file
77
app/Filament/Resources/Oauth/RefreshTokenResource.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth;
|
||||
|
||||
use App\Filament\Resources\Oauth\RefreshTokenResource\Pages;
|
||||
use App\Filament\Resources\Oauth\RefreshTokenResource\RelationManagers;
|
||||
use Laravel\Passport\RefreshToken;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Resources\Table;
|
||||
use Filament\Tables;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class RefreshTokenResource extends Resource
|
||||
{
|
||||
protected static ?string $model = RefreshToken::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
|
||||
protected static ?string $navigationGroup = 'Oauth';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
protected static function getNavigationLabel(): string
|
||||
{
|
||||
return __('admin.sidebar.oauth_refresh_token');
|
||||
}
|
||||
|
||||
public static function getBreadcrumb(): string
|
||||
{
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->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('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Oauth\RefreshTokenResource\Pages;
|
||||
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\Oauth\RefreshTokenResource;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageRefreshTokens extends PageListSingle
|
||||
{
|
||||
protected static string $resource = RefreshTokenResource::class;
|
||||
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class Authenticate extends Middleware
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return getBaseUrl() . '/login.php';
|
||||
return sprintf("%s/login.php?returnto=%s", $request->getSchemeAndHttpHost(), urlencode($request->fullUrl()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class NexusAuth extends Middleware
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
return getBaseUrl() . '/login.php';
|
||||
return sprintf("%s/login.php?returnto=%s", $request->getSchemeAndHttpHost(), urlencode($request->fullUrl()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
'Role & Permission',
|
||||
'Other',
|
||||
'Section',
|
||||
'Oauth',
|
||||
'System',
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1106,6 +1106,27 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
// printProgress($log);
|
||||
// }
|
||||
|
||||
sql_query("delete from oauth_auth_codes where expires_at <= '$nowStr'");
|
||||
$log = "delete oauth auth code expired";
|
||||
do_log($log);
|
||||
if ($printProgress) {
|
||||
printProgress($log);
|
||||
}
|
||||
|
||||
sql_query("delete from oauth_access_tokens where expires_at <= '$nowStr'");
|
||||
$log = "delete oauth access token expired";
|
||||
do_log($log);
|
||||
if ($printProgress) {
|
||||
printProgress($log);
|
||||
}
|
||||
|
||||
sql_query("delete from oauth_refresh_tokens where expires_at <= '$nowStr'");
|
||||
$log = "delete oauth refresh token expired";
|
||||
do_log($log);
|
||||
if ($printProgress) {
|
||||
printProgress($log);
|
||||
}
|
||||
|
||||
$log = 'Full cleanup is done';
|
||||
do_log($log);
|
||||
if ($printProgress) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.9');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-03-08');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-03-11');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -38,6 +38,10 @@ return [
|
||||
'bonus_log' => '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' => [
|
||||
|
||||
9
resources/lang/en/oauth.php
Normal file
9
resources/lang/en/oauth.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'client' => 'Client',
|
||||
'redirect' => 'Redirect URL',
|
||||
'secret' => 'Secret',
|
||||
'revoked' => 'Valid',
|
||||
'access_token' => 'Access token',
|
||||
'refresh_token' => 'Refresh token',
|
||||
];
|
||||
@@ -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' => [
|
||||
|
||||
9
resources/lang/zh_CN/oauth.php
Normal file
9
resources/lang/zh_CN/oauth.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'client' => '客户端',
|
||||
'redirect' => '回调地址',
|
||||
'secret' => '密钥',
|
||||
'revoked' => '有效',
|
||||
'access_token' => '访问令牌',
|
||||
'refresh_token' => '刷新令牌',
|
||||
];
|
||||
@@ -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' => [
|
||||
|
||||
9
resources/lang/zh_TW/oauth.php
Normal file
9
resources/lang/zh_TW/oauth.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'client' => '客戶端',
|
||||
'redirect' => '回調地址',
|
||||
'secret' => '密鑰',
|
||||
'revoked' => '有效',
|
||||
'access_token' => '訪問令牌',
|
||||
'refresh_token' => '刷新令牌',
|
||||
];
|
||||
Reference in New Issue
Block a user