Skip to content

Commit 6f9f1d5

Browse files
committed
fix: org scoping in the select plan flow
Adds proper org scoping in the loader and action in the plans page.
1 parent d10281e commit 6f9f1d5

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.billing/route.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const meta: MetaFunction = () => {
2828
};
2929

3030
export async function loader({ params, request }: LoaderFunctionArgs) {
31-
await requireUserId(request);
31+
const userId = await requireUserId(request);
3232
const { organizationSlug } = OrganizationParamsSchema.parse(params);
3333

3434
const { isManagedCloud } = featuresForRequest(request);
@@ -41,8 +41,8 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
4141
throw new Response(null, { status: 404, statusText: "Plans not found" });
4242
}
4343

44-
const organization = await prisma.organization.findUnique({
45-
where: { slug: organizationSlug },
44+
const organization = await prisma.organization.findFirst({
45+
where: { slug: organizationSlug, members: { some: { userId } } },
4646
});
4747

4848
if (!organization) {

apps/webapp/app/routes/resources.orgs.$organizationSlug.select-plan.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import {
77
} from "@heroicons/react/20/solid";
88
import { ArrowDownCircleIcon, ArrowUpCircleIcon } from "@heroicons/react/24/outline";
99
import { Form, useLocation, useNavigation } from "@remix-run/react";
10-
import { ActionFunctionArgs } from "@remix-run/server-runtime";
10+
import { type ActionFunctionArgs } from "@remix-run/server-runtime";
1111
import { uiComponent } from "@team-plain/typescript-sdk";
1212
import { GitHubLightIcon } from "@trigger.dev/companyicons";
1313
import {
14-
FreePlanDefinition,
15-
Limits,
16-
PaidPlanDefinition,
17-
Plans,
18-
SetPlanBody,
19-
SubscriptionResult,
14+
type FreePlanDefinition,
15+
type Limits,
16+
type PaidPlanDefinition,
17+
type Plans,
18+
type SetPlanBody,
19+
type SubscriptionResult,
2020
} from "@trigger.dev/platform";
2121
import React, { useEffect, useState } from "react";
2222
import { z } from "zod";
@@ -75,8 +75,8 @@ export async function action({ request, params }: ActionFunctionArgs) {
7575
message: message || undefined,
7676
});
7777

78-
const organization = await prisma.organization.findUnique({
79-
where: { slug: organizationSlug },
78+
const organization = await prisma.organization.findFirst({
79+
where: { slug: organizationSlug, members: { some: { userId: user.id } } },
8080
});
8181

8282
if (!organization) {

0 commit comments

Comments
 (0)