Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/php8' into php8
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Mar 12, 2024
2 parents f3c1f2c + 8903f10 commit 79208b0
Show file tree
Hide file tree
Showing 22 changed files with 459 additions and 10 deletions.
10 changes: 8 additions & 2 deletions app/Auth/NexusWebGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ public function validate(array $credentials = [])
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()
Expand Down
3 changes: 2 additions & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function register()
}
});
$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
Expand Down
6 changes: 2 additions & 4 deletions app/Filament/PageListSingle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ protected function getTableFiltersLayout(): ?string
return Layout::AboveContent;
}

protected function getTableRecordUrlUsing(): ?Closure
protected function getTableRecordActionUsing(): ?Closure
{
return function (Model $record): ?string {
return null;
};
return null;
}
}
76 changes: 76 additions & 0 deletions app/Filament/Resources/Oauth/AccessTokenResource.php
Original file line number Diff line number Diff line change
@@ -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('/'),
];
}
}
Original file line number Diff line number Diff line change
@@ -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 changes: 75 additions & 0 deletions app/Filament/Resources/Oauth/AuthCodeResource.php
Original file line number Diff line number Diff line change
@@ -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('/'),
];
}
}
Original file line number Diff line number Diff line change
@@ -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 changes: 75 additions & 0 deletions app/Filament/Resources/Oauth/ClientResource.php
Original file line number Diff line number Diff line change
@@ -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('/'),
];
}
}
Original file line number Diff line number Diff line change
@@ -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(),
];
}
}
Loading

0 comments on commit 79208b0

Please sign in to comment.