Skip to content

Commit 6ba3049

Browse files
authored
fix: unauthorized trpc error in /getting-started page (#23040)
1 parent abe92cd commit 6ba3049

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

apps/web/app/(use-page-wrapper)/getting-started/[[...step]]/page.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createRouterCaller } from "app/_trpc/context";
12
import type { PageProps as ServerPageProps } from "app/_types";
23
import { _generateMetadata } from "app/_utils";
34
import { cookies, headers } from "next/headers";
@@ -7,6 +8,7 @@ import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
78
import { APP_NAME } from "@calcom/lib/constants";
89
import { UserRepository } from "@calcom/lib/server/repository/user";
910
import prisma from "@calcom/prisma";
11+
import { meRouter } from "@calcom/trpc/server/routers/viewer/me/_router";
1012

1113
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
1214

@@ -32,15 +34,20 @@ const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
3234
}
3335

3436
const userRepo = new UserRepository(prisma);
35-
const user = await userRepo.findUserTeams({
36-
id: session.user.id,
37-
});
37+
const meCaller = await createRouterCaller(meRouter);
3838

39-
if (!user) {
39+
const [userTeams, user] = await Promise.all([
40+
userRepo.findUserTeams({
41+
id: session.user.id,
42+
}),
43+
meCaller.get(),
44+
]);
45+
46+
if (!userTeams || !user) {
4047
return redirect("/auth/login");
4148
}
4249

43-
return <Page hasPendingInvites={!!user.teams.find((team) => team.accepted === false)} />;
50+
return <Page user={user} hasPendingInvites={!!userTeams.teams.find((team) => team.accepted === false)} />;
4451
};
4552

4653
export default ServerPage;

apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import { z } from "zod";
1010
import { APP_NAME } from "@calcom/lib/constants";
1111
import { useLocale } from "@calcom/lib/hooks/useLocale";
1212
import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback";
13-
import { trpc } from "@calcom/trpc";
14-
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
13+
import type { RouterOutputs } from "@calcom/trpc/react";
1514
import classNames from "@calcom/ui/classNames";
1615
import { Button } from "@calcom/ui/components/button";
1716
import { StepCard } from "@calcom/ui/components/card";
@@ -85,13 +84,14 @@ const stepRouteSchema = z.object({
8584

8685
type PageProps = {
8786
hasPendingInvites: boolean;
87+
user: RouterOutputs["viewer"]["me"]["get"];
8888
};
89+
8990
const OnboardingPage = (props: PageProps) => {
9091
const pathname = usePathname();
9192
const params = useParamsWithFallback();
92-
93+
const user = props.user;
9394
const router = useRouter();
94-
const [user] = trpc.viewer.me.get.useSuspenseQuery();
9595
const { t } = useLocale();
9696
const [isNextStepLoading, startTransition] = useTransition();
9797

0 commit comments

Comments
 (0)