Skip to content

Commit 671ed38

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

3 files changed

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

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)