- Terms accepted, if the page does not reload please refresh and
+ Terms accepted. If the page does not reload please refresh and
navigate to home.
diff --git a/apps/nextjs/src/middlewares/auth.middleware.ts b/apps/nextjs/src/middlewares/auth.middleware.ts
index b104c070b..16b41e676 100644
--- a/apps/nextjs/src/middlewares/auth.middleware.ts
+++ b/apps/nextjs/src/middlewares/auth.middleware.ts
@@ -58,9 +58,8 @@ const isPreloadableRoute = createRouteMatcher([
"/aila",
]);
-const onboardingUrl = "/onboarding";
const isOnboardingRoute = createRouteMatcher([
- onboardingUrl,
+ "/onboarding",
"/sign-in",
// NOTE: Be careful that this request doesn't batch as it will change the path
"/api/trpc/main/auth.setDemoStatus",
diff --git a/packages/api/src/router/auth.ts b/packages/api/src/router/auth.ts
index 24f6168cb..63151afe7 100644
--- a/packages/api/src/router/auth.ts
+++ b/packages/api/src/router/auth.ts
@@ -70,38 +70,35 @@ export const authRouter = router({
setDemoStatus: protectedProcedure.mutation(async ({ ctx }) => {
const { userId } = ctx.auth;
- if (typeof userId === "string") {
- const user = await clerkClient.users.getUser(userId);
+ const user = await clerkClient.users.getUser(userId);
- if (demoUsers.isDemoStatusSet(user)) {
- return { isDemoUser: user.publicMetadata.labs };
- }
+ if (demoUsers.isDemoStatusSet(user)) {
+ return { isDemoUser: user.publicMetadata.labs };
+ }
- const { region, isDemoRegion: isDemoUser } =
- await demoUsers.getUserRegion(
- user,
- ctx.req.headers.get("cf-ipcountry"),
- );
+ const { region, isDemoRegion: isDemoUser } = await demoUsers.getUserRegion(
+ user,
+ ctx.req.headers.get("cf-ipcountry"),
+ );
- await clerkClient.users.updateUserMetadata(userId, {
- publicMetadata: {
- labs: {
- isDemoUser,
- },
- },
- privateMetadata: {
- region,
- },
- });
-
- await posthogServerClient.identify({
- distinctId: userId,
- properties: {
+ await clerkClient.users.updateUserMetadata(userId, {
+ publicMetadata: {
+ labs: {
isDemoUser,
},
- });
+ },
+ privateMetadata: {
+ region,
+ },
+ });
- return { isDemoUser };
- }
+ posthogServerClient.identify({
+ distinctId: userId,
+ properties: {
+ isDemoUser,
+ },
+ });
+
+ return { isDemoUser };
}),
});
diff --git a/packages/core/src/models/demoUsers.ts b/packages/core/src/models/demoUsers.ts
index 80304cd5a..e9a6c668e 100644
--- a/packages/core/src/models/demoUsers.ts
+++ b/packages/core/src/models/demoUsers.ts
@@ -19,7 +19,7 @@ type LabsUser = User & {
};
};
-type UserWithDemoStatus = User & {
+type UserWithDemoStatus = LabsUser & {
publicMetadata: {
labs: {
isDemoUser: boolean;