Skip to content

Commit

Permalink
Merge pull request #4472 from systeminit/feat(auth-portal,-auth-api)-…
Browse files Browse the repository at this point in the history
…Enable-simplified-signup-for-systeminit-users

feat(auth-portal, auth-api): Enable simplified signup for systeminit users
  • Loading branch information
stack72 authored Aug 30, 2024
2 parents 9b4e3d5 + 1ffde29 commit 857c552
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/auth-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -52,4 +52,4 @@
"volta": {
"extends": "../../package.json"
}
}
}
7 changes: 5 additions & 2 deletions app/auth-portal/src/pages/DefaultWorkspacePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 3 additions & 8 deletions app/auth-portal/src/pages/ProfilePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand Down
31 changes: 23 additions & 8 deletions bin/auth-api/src/services/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 2 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 857c552

Please sign in to comment.