fix(signup): keep default-workspace creation inside the registration transaction
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.
This commit is contained in:
parent
caad3d3e53
commit
3d01f3aab4
1 changed files with 6 additions and 7 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue