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.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
feat(onboarding): auto-create a default workspace at signup
Paulo Castellanob7374c1adb22
diff --git a/app/Actions/User/CreateUser.php b/app/Actions/User/CreateUser.phpindex f6c0c1eb2..ead5eca04 100644--- a/app/Actions/User/CreateUser.php+++ b/app/Actions/User/CreateUser.php@@ -4,6 +4,7 @@ declare(strict_types=1);namespace App\Actions\User;+use App\Actions\Workspace\CreateWorkspace;use App\Enums\Plan\Slug;use App\Jobs\PostHog\SyncUser;use App\Models\Account;@@ -48,6 +49,10 @@ class CreateUser$account->update(['owner_id' => $user->id]);+ if (! $isInviteRegistration) {+ CreateWorkspace::execute($user, ['name' => data_get($data, 'name')."'s Workspace"]);+ }+return $user;});diff --git a/database/seeders/UserSeeder.php b/database/seeders/UserSeeder.phpindex a3a28b5d5..68c7ca28d 100644--- a/database/seeders/UserSeeder.php+++ b/database/seeders/UserSeeder.php@@ -5,7 +5,6 @@ declare(strict_types=1);namespace Database\Seeders;use App\Actions\User\CreateUser;-use App\Actions\Workspace\CreateWorkspace;use App\Models\User;use Illuminate\Database\Seeder;@@ -19,7 +18,7 @@ class UserSeeder extends Seederreturn;}- $user = CreateUser::execute([+ CreateUser::execute(['name' => 'Admin','email' => '[email protected]','password' => 'password',@@ -27,8 +26,6 @@ class UserSeeder extends Seeder'timezone' => 'UTC',]);- CreateWorkspace::execute($user, ['name' => 'My Workspace']);-$this->command->info('Admin account created — change the password on first login:');$this->command->line(' email: [email protected]');$this->command->line(' password: password');diff --git a/resources/js/pages/billing/Processing.vue b/resources/js/pages/billing/Processing.vueindex 5220708ff..96673402b 100644--- a/resources/js/pages/billing/Processing.vue+++ b/resources/js/pages/billing/Processing.vue@@ -4,7 +4,7 @@ import { IconLoader2 } from '@tabler/icons-vue';import { onMounted, ref, watch } from 'vue';import { useTracking } from '@/composables/useTracking';-import { home } from '@/routes/app';+import { accounts } from '@/routes/app';import type { Auth } from '@/types';const props = defineProps<{@@ -27,7 +27,7 @@ const { trackPurchase } = useTracking();const tracked = ref(false);-const goHome = () => router.visit(home.url());+const goToAccounts = () => router.visit(accounts.url({ query: { openDialog: true } }));// Fires `checkout.completed` exactly once for a real checkout. A trial-with-card// subscription is already `subscribed()` (status `trialing`) by the time the@@ -53,7 +53,7 @@ const completePurchase = () => {}}- goHome();+ goToAccounts();};watch(diff --git a/tests/Feature/Actions/User/CreateUserTest.php b/tests/Feature/Actions/User/CreateUserTest.phpindex 353f47cc1..570ea539c 100644--- a/tests/Feature/Actions/User/CreateUserTest.php+++ b/tests/Feature/Actions/User/CreateUserTest.php@@ -8,7 +8,7 @@ use App\Models\Account;use App\Models\Workspace;use Illuminate\Support\Facades\Bus;-test('CreateUser creates user with account but no workspace and no current_workspace_id', function () {+test('CreateUser creates the owner a default workspace and sets it as current', function () {$user = CreateUser::execute(['name' => 'Jane Doe','email' => '[email protected]',@@ -17,10 +17,14 @@ test('CreateUser creates user with account but no workspace and no current_worksexpect($user->name)->toBe('Jane Doe');expect($user->email)->toBe('[email protected]');- expect($user->current_workspace_id)->toBeNull();expect($user->account_id)->not->toBeNull();- expect(Workspace::count())->toBe(0);expect(Account::find($user->account_id))->not->toBeNull();++ $workspace = $user->workspaces()->first();+ expect($user->workspaces()->count())->toBe(1);+ expect($workspace->name)->toBe("Jane Doe's Workspace");+ expect($workspace->account_id)->toBe($user->account_id);+ expect($user->fresh()->current_workspace_id)->toBe($workspace->id);});test('CreateUser sets account owner_id to the new user', function () {diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.phpindex 495791ca2..39aae50d5 100644--- a/tests/Feature/Auth/RegistrationTest.php+++ b/tests/Feature/Auth/RegistrationTest.php@@ -24,7 +24,7 @@ test('new users can register', function () {$response->assertRedirect(route('register.success', absolute: false));});-test('new users do not get a default workspace on registration', function () {+test('new users get a default workspace on registration', function () {$this->post(route('register.store'), ['name' => 'Test User','email' => '[email protected]',@@ -35,8 +35,9 @@ test('new users do not get a default workspace on registration', function () {expect($user)->not->toBeNull();expect($user->account_id)->not->toBeNull();- expect($user->workspaces()->count())->toBe(0);- expect($user->current_workspace_id)->toBeNull();+ expect($user->workspaces()->count())->toBe(1);+ expect($user->workspaces()->first()->name)->toBe("Test User's Workspace");+ expect($user->current_workspace_id)->toBe($user->workspaces()->first()->id);});test('new users can register with a timezone preference', function () {@@ -50,7 +51,7 @@ test('new users can register with a timezone preference', function () {$user = User::where('email', '[email protected]')->first();expect($user)->not->toBeNull();- expect($user->workspaces()->count())->toBe(0);+ expect($user->workspaces()->count())->toBe(1);});test('new users do not have verified email by default', function () {diff --git a/tests/Feature/SocialLoginControllerTest.php b/tests/Feature/SocialLoginControllerTest.phpindex b0df02843..9fb08ccd3 100644--- a/tests/Feature/SocialLoginControllerTest.php+++ b/tests/Feature/SocialLoginControllerTest.php@@ -66,8 +66,9 @@ test('google callback creates new user when email does not exist', function () {expect($user->name)->toBe('New User');expect($user->email_verified_at)->not->toBeNull();expect($user->account_id)->not->toBeNull();- expect($user->workspaces()->count())->toBe(0);- expect($user->current_workspace_id)->toBeNull();+ expect($user->workspaces()->count())->toBe(1);+ expect($user->workspaces()->first()->name)->toBe("New User's Workspace");+ expect($user->current_workspace_id)->toBe($user->workspaces()->first()->id);$this->assertAuthenticatedAs($user);});