From 3d01f3aab4f2f4b137d5dc5113c77558e2481b26 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Mon, 22 Jun 2026 08:47:47 -0300 Subject: [PATCH] fix(signup): keep default-workspace creation inside the registration transaction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts the CreateWorkspace-outside-transaction change from the previous commit. That move was based on a mis-framed concern: forgetPlanFeatureCache() uses Pennant's default 'database' store (no config/pennant.php), so it's a DB write, not an external cache call — safe inside a DB transaction. Moving CreateWorkspace out introduced two failure-path regressions: a stranded half-registered account (user committed but not logged in, blocked from retrying by unique:users) and an orphan workspace inflating the Stripe quantity. Back inside the transaction the whole signup is atomic again. --- app/Actions/User/CreateUser.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Actions/User/CreateUser.php b/app/Actions/User/CreateUser.php index 7f7f5e7b..ead5eca0 100644 --- a/app/Actions/User/CreateUser.php +++ b/app/Actions/User/CreateUser.php @@ -21,9 +21,8 @@ class CreateUser */ public static function execute(array $data, array $utmParameters = []): User { - $isInviteRegistration = (bool) data_get($data, 'is_invite', false); - - $user = DB::transaction(function () use ($data, $utmParameters, $isInviteRegistration): User { + $user = DB::transaction(function () use ($data, $utmParameters): User { + $isInviteRegistration = data_get($data, 'is_invite', false); $requiresCardForTrial = (bool) config('trypost.billing.require_card_for_trial', true); $accountAttributes = [ 'name' => data_get($data, 'name')."'s Account", @@ -50,13 +49,13 @@ public static function execute(array $data, array $utmParameters = []): User $account->update(['owner_id' => $user->id]); + if (! $isInviteRegistration) { + CreateWorkspace::execute($user, ['name' => data_get($data, 'name')."'s Workspace"]); + } + return $user; }); - if (! $isInviteRegistration) { - CreateWorkspace::execute($user, ['name' => data_get($data, 'name')."'s Workspace"]); - } - if (PostHogService::isEnabled()) { SyncUser::dispatch((string) $user->id); }