Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

fix(signup): keep default-workspace creation inside the registration transaction

Paulo Castellano3d01f3aab4f2
diff --git a/app/Actions/User/CreateUser.php b/app/Actions/User/CreateUser.php
index 7f7f5e7b3..ead5eca04 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 @@ class CreateUser
$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);
}