Skip to content

Commit dd31774

Browse files
committed
Use migration suggested in docs
1 parent 4f4b217 commit dd31774

3 files changed

Lines changed: 51 additions & 90 deletions

File tree

‎ProcessMaker/Providers/ProcessMakerServiceProvider.php‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Laravel\Horizon\Horizon;
2424
use Laravel\Horizon\SystemProcessCounter;
2525
use Laravel\Horizon\WorkerCommandString;
26-
use Laravel\Passport\Client as PassportClient;
2726
use Lavary\Menu\Menu;
2827
use OpenApi\Analysers\AttributeAnnotationFactory;
2928
use OpenApi\Analysers\DocBlockAnnotationFactory;
@@ -355,24 +354,6 @@ protected static function bootObservers(): void
355354
Models\ProcessRequestToken::observe(Observers\ProcessRequestTokenObserver::class);
356355

357356
Models\ProcessCollaboration::observe(Observers\ProcessCollaborationObserver::class);
358-
359-
// Due to this change https://github.com/laravel/passport/blob/ea020190123953426a439f0267c6cfa478f6e6e7/src/Guards/TokenGuard.php#L146
360-
// user ID is now required for bearer tokens clients. Any user will work here, the token itself
361-
// is what's associated with the real user. For now, we'll use the first administrator user.
362-
PassportClient::creating(function (PassportClient $client): void {
363-
if (!$client->personal_access_client || $client->user_id !== null) {
364-
return;
365-
}
366-
367-
$adminUserId = Models\User::query()
368-
->where('is_administrator', true)
369-
->orderBy('id')
370-
->value('id');
371-
372-
if ($adminUserId !== null) {
373-
$client->user_id = $adminUserId;
374-
}
375-
});
376357
}
377358

378359
/**
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
use Laravel\Passport\Passport;
7+
8+
return new class extends Migration {
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
// Copied from https://github.com/jaapredeker/passport/blob/021ab9adafbbaed1d600869ca891586ca99b2f49/UPGRADE.md#oauth-client-table-changes
15+
16+
Schema::table('oauth_clients', function (Blueprint $table) {
17+
$table->nullableMorphs('owner', after: 'user_id');
18+
19+
$table->after('provider', function (Blueprint $table) {
20+
$table->text('redirect_uris')->nullable();
21+
$table->text('grant_types')->nullable();
22+
});
23+
});
24+
25+
foreach (Passport::client()->cursor() as $client) {
26+
Model::withoutTimestamps(fn () => $client->forceFill([
27+
'owner_id' => $client->user_id,
28+
'owner_type' => $client->user_id
29+
? config('auth.providers.' . ($client->provider ?: config('auth.guards.api.provider')) . '.model')
30+
: null,
31+
'redirect_uris' => $client->redirect_uris,
32+
'grant_types' => $client->grant_types,
33+
])->save());
34+
}
35+
36+
Schema::table('oauth_clients', function (Blueprint $table) {
37+
$table->dropColumn(['user_id', 'redirect', 'personal_access_client', 'password_client']);
38+
39+
$table->text('redirect_uris')->nullable(false)->change();
40+
$table->text('grant_types')->nullable(false)->change();
41+
});
42+
}
43+
44+
/**
45+
* Reverse the migrations.
46+
*/
47+
public function down(): void
48+
{
49+
//
50+
}
51+
};

‎upgrades/2026_05_07_212653_set_user_id_on_oauth_client.php‎

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)