From 1ffde29f2485fe9923f49e0486d4352c504384ce Mon Sep 17 00:00:00 2001 From: stack72 Date: Fri, 30 Aug 2024 22:33:57 +0100 Subject: [PATCH] feat(auth-portal, auth-api): Enable simplified signup for systeminit users --- app/auth-portal/package.json | 4 +-- .../src/pages/DefaultWorkspacePage.vue | 7 +++-- app/auth-portal/src/pages/ProfilePage.vue | 11 ++----- bin/auth-api/src/services/users.service.ts | 31 ++++++++++++++----- pnpm-lock.yaml | 10 ++---- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/app/auth-portal/package.json b/app/auth-portal/package.json index db6b484a2e..a42325460d 100644 --- a/app/auth-portal/package.json +++ b/app/auth-portal/package.json @@ -27,7 +27,7 @@ "local-storage-fallback": "^4.1.2", "lodash-es": "^4.17.21", "pinia": "^2.1.7", - "posthog-js": "^1.76.0", + "posthog-js": "^1.155.0", "vite-ssg": "^0.23.5", "vue": "^3.4.15", "vue-router": "^4.2.5" @@ -52,4 +52,4 @@ "volta": { "extends": "../../package.json" } -} \ No newline at end of file +} diff --git a/app/auth-portal/src/pages/DefaultWorkspacePage.vue b/app/auth-portal/src/pages/DefaultWorkspacePage.vue index f8886d7646..1449407f10 100644 --- a/app/auth-portal/src/pages/DefaultWorkspacePage.vue +++ b/app/auth-portal/src/pages/DefaultWorkspacePage.vue @@ -14,8 +14,11 @@ const defaultWorkspace = computed(() => workspacesStore.defaultWorkspace); onMounted(async () => { if (import.meta.env.SSR) return; - if (!authStore.userIsLoggedIn) return; - + if ( + !authStore.userIsLoggedIn || + !authStore.user?.onboardingDetails?.reviewedProfile + ) + return; // eslint-disable-next-line @typescript-eslint/no-floating-promises await workspacesStore.LOAD_WORKSPACES(); if (defaultWorkspace.value) { diff --git a/app/auth-portal/src/pages/ProfilePage.vue b/app/auth-portal/src/pages/ProfilePage.vue index e0948c31a7..954058a007 100644 --- a/app/auth-portal/src/pages/ProfilePage.vue +++ b/app/auth-portal/src/pages/ProfilePage.vue @@ -229,14 +229,9 @@ const saveHandler = async () => { const completeProfileReq = await authStore.COMPLETE_PROFILE({}); if (completeProfileReq.result.success) { - if (featureFlagsStore.SIMPLIFIED_SIGNUP) { - if (authStore.user?.emailVerified && workspacesStore.defaultWorkspace) { - tracker.trackEvent("workspace_launcher_widget_click"); - window.location.href = `${API_HTTP_URL}/workspaces/${workspacesStore.defaultWorkspace.id}/go`; - } else { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - router.push({ name: "login-success" }); - } + if (authStore.user?.emailVerified && workspacesStore.defaultWorkspace) { + tracker.trackEvent("workspace_launcher_widget_click"); + window.location.href = `${API_HTTP_URL}/workspaces/${workspacesStore.defaultWorkspace.id}/go`; } else { // eslint-disable-next-line @typescript-eslint/no-floating-promises router.push({ name: "workspaces" }); diff --git a/bin/auth-api/src/services/users.service.ts b/bin/auth-api/src/services/users.service.ts index 26f9bf3a7b..7975d69241 100644 --- a/bin/auth-api/src/services/users.service.ts +++ b/bin/auth-api/src/services/users.service.ts @@ -3,7 +3,11 @@ import { ulid } from "ulidx"; import * as Auth0 from "auth0"; import { InstanceEnvType, Prisma, PrismaClient } from "@prisma/client"; -import { createWorkspace, LOCAL_WORKSPACE_URL } from "./workspaces.service"; +import { + createWorkspace, + LOCAL_WORKSPACE_URL, + SAAS_WORKSPACE_URL, +} from "./workspaces.service"; import { LATEST_TOS_VERSION_ID } from "./tos.service"; import { tracker } from "../lib/tracker"; import { fetchAuth0Profile } from "./auth0.service"; @@ -142,17 +146,28 @@ export async function createOrUpdateUserFromAuth0Details( lastName: user.lastName, }); + if (user.email.includes("@systeminit.com")) { + await createWorkspace( + user, + InstanceEnvType.SI, + SAAS_WORKSPACE_URL, + `${user.nickname}'s Production Workspace`, + true, + ); + } else { + await createWorkspace( + user, + InstanceEnvType.LOCAL, + LOCAL_WORKSPACE_URL, + `${user.nickname}'s Dev Workspace`, + false, + ); + } + // create a default saas workspace // await createWorkspace(user, InstanceEnvType.SI, "https://app.systeminit.com", `${user.nickname}'s Production Workspace`); // we want to check if this is the first production workspace that a user has and if so, we are going to set it as the default // when we launch this feature! - await createWorkspace( - user, - InstanceEnvType.LOCAL, - LOCAL_WORKSPACE_URL, - `${user.nickname}'s Dev Workspace`, - false, - ); } return user; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9442fbe724..6f7e95a1ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,8 +44,8 @@ importers: specifier: ^2.1.7 version: 2.1.7(typescript@4.9.5)(vue@3.4.15) posthog-js: - specifier: ^1.76.0 - version: 1.76.0 + specifier: ^1.155.0 + version: 1.155.0 vite-ssg: specifier: ^0.23.5 version: 0.23.5(vite@5.0.10)(vue-router@4.2.5)(vue@3.4.15) @@ -16520,12 +16520,6 @@ packages: rrweb-snapshot: 1.1.14 dev: false - /posthog-js@1.76.0: - resolution: {integrity: sha512-C/+M+uVQ+CAEUz0ZAENMobw0fYcXGNomUXd8irelT7cQ9fsDSRgfyF5wwqaX0UXcIBD+iFXTOtK93T8NnFODyg==} - dependencies: - fflate: 0.4.8 - dev: false - /posthog-node@2.6.0(debug@4.3.4): resolution: {integrity: sha512-/BiFw/jwdP0uJSRAIoYqLoBTjZ612xv74b1L/a3T/p1nJVL8e0OrHuxbJW56c6WVW/IKm9gBF/zhbqfaz0XgJQ==} engines: {node: '>=15.0.0'}