Skip to content

Commit c945ed9

Browse files
committed
skip project check if no orgs found
1 parent 729c68a commit c945ed9

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

apps/webapp/app/routes/api.v2.whoami.ts

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,38 @@ export async function loader({ request }: LoaderFunctionArgs) {
4747
},
4848
});
4949

50-
const project = await prisma.project.findFirst({
51-
select: {
52-
externalRef: true,
53-
name: true,
54-
slug: true,
55-
organization: {
56-
select: {
57-
slug: true,
58-
title: true,
50+
if (orgs.length > 0) {
51+
const project = await prisma.project.findFirst({
52+
select: {
53+
externalRef: true,
54+
name: true,
55+
slug: true,
56+
organization: {
57+
select: {
58+
slug: true,
59+
title: true,
60+
},
5961
},
6062
},
61-
},
62-
where: {
63-
externalRef: projectRef,
64-
organizationId: {
65-
in: orgs.map((org) => org.id),
63+
where: {
64+
externalRef: projectRef,
65+
organizationId: {
66+
in: orgs.map((org) => org.id),
67+
},
6668
},
67-
},
68-
});
69+
});
6970

70-
if (project) {
71-
const projectPath = v3ProjectPath(
72-
{ slug: project.organization.slug },
73-
{ slug: project.slug }
74-
);
75-
projectDetails = {
76-
url: new URL(projectPath, env.APP_ORIGIN).href,
77-
name: project.name,
78-
orgTitle: project.organization.title,
79-
};
71+
if (project) {
72+
const projectPath = v3ProjectPath(
73+
{ slug: project.organization.slug },
74+
{ slug: project.slug }
75+
);
76+
projectDetails = {
77+
url: new URL(projectPath, env.APP_ORIGIN).href,
78+
name: project.name,
79+
orgTitle: project.organization.title,
80+
};
81+
}
8082
}
8183
}
8284

0 commit comments

Comments
 (0)