From 73bd3a1eaac97a994c7e3820ae6121e0a9131e49 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 18 Mar 2024 02:57:55 +0800 Subject: [PATCH] fix oauth client secret --- app/Filament/Resources/Oauth/ClientResource.php | 4 ++-- app/Models/OauthClient.php | 7 +++++++ include/constants.php | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/Oauth/ClientResource.php b/app/Filament/Resources/Oauth/ClientResource.php index 6c4c47ddf..fd143cac8 100644 --- a/app/Filament/Resources/Oauth/ClientResource.php +++ b/app/Filament/Resources/Oauth/ClientResource.php @@ -6,7 +6,7 @@ use App\Filament\PageListSingle; use App\Filament\Resources\Oauth\ClientResource\Pages; use App\Filament\Resources\Oauth\ClientResource\RelationManagers; -use Laravel\Passport\Client; +use App\Models\OauthClient; use Filament\Forms; use Filament\Resources\Form; use Filament\Resources\Resource; @@ -19,7 +19,7 @@ class ClientResource extends Resource { use OptionsTrait; - protected static ?string $model = Client::class; + protected static ?string $model = OauthClient::class; protected static ?string $navigationIcon = 'heroicon-o-collection'; diff --git a/app/Models/OauthClient.php b/app/Models/OauthClient.php index 6c9de2f76..77bae9f5e 100644 --- a/app/Models/OauthClient.php +++ b/app/Models/OauthClient.php @@ -2,10 +2,17 @@ namespace App\Models; +use Illuminate\Support\Str; use Laravel\Passport\Client; class OauthClient extends Client { + protected static function booted(): void + { + static::creating(function (OauthClient $model) { + $model->secret = Str::random(40); + }); + } public function skipsAuthorization(): bool { return (bool)$this->skips_authorization; diff --git a/include/constants.php b/include/constants.php index bfece3db0..3f1f2a073 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@