diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index 302054b7f..0ad194cb2 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -2,6 +2,7 @@ namespace App\Actions\Fortify; +use App\Jobs\NotifySetupCompleteJob; use App\Models\User; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; @@ -56,7 +57,18 @@ public function create(array $input): User // Disable registration after first user is created $settings = instanceSettings(); $settings->is_registration_enabled = false; + + // MapleDeploy: notify control plane that setup is complete + // Capture token before clearing so the job can authenticate with it + $callbackUrl = $settings->setup_callback_url; + $token = $settings->setup_token; + $settings->setup_token = null; + $settings->setup_callback_url = null; $settings->save(); + + if ($callbackUrl && $token) { + NotifySetupCompleteJob::dispatch($token, $callbackUrl); + } } else { $user = User::create([ 'name' => $input['name'], diff --git a/app/Jobs/NotifySetupCompleteJob.php b/app/Jobs/NotifySetupCompleteJob.php new file mode 100644 index 000000000..b8a8c8d06 --- /dev/null +++ b/app/Jobs/NotifySetupCompleteJob.php @@ -0,0 +1,55 @@ +onQueue('high'); + } + + public function handle(): void + { + $response = Http::withToken($this->setupToken) + ->timeout(15) + ->post($this->callbackUrl); + + if (! $response->successful()) { + Log::warning('Setup-complete callback failed', [ + 'status' => $response->status(), + 'url' => $this->callbackUrl, + ]); + + // Throw so the job retries + throw new \RuntimeException( + "Setup-complete callback returned HTTP {$response->status()}" + ); + } + } +} diff --git a/database/migrations/2026_02_22_000001_add_setup_callback_url_to_instance_settings_table.php b/database/migrations/2026_02_22_000001_add_setup_callback_url_to_instance_settings_table.php new file mode 100644 index 000000000..286299b1f --- /dev/null +++ b/database/migrations/2026_02_22_000001_add_setup_callback_url_to_instance_settings_table.php @@ -0,0 +1,28 @@ +string('setup_callback_url')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('instance_settings', function (Blueprint $table) { + $table->dropColumn('setup_callback_url'); + }); + } +};