From 29abc4782044f549004384c557458fbcf80d27be Mon Sep 17 00:00:00 2001 From: Ivan Starkov Date: Wed, 8 May 2024 23:29:13 +0300 Subject: [PATCH] fix: Do not check user authenticated on trpc (#3330) ## Description We should not check user auth on trpc, context security is enough ## Steps for reproduction Open in Incognito https://trpc-auth.staging.webstudio.is/builder/95821bd9-040a-4294-aa7f-edf26d7f1ebe?authToken=137726f9-7914-4807-8d62-091eea59296b&mode=edit Click publish ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env.example` and the `builder/env-check.js` if mandatory --- apps/builder/app/routes/trpc.$.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/apps/builder/app/routes/trpc.$.ts b/apps/builder/app/routes/trpc.$.ts index b57954d08a..ad633a3a22 100644 --- a/apps/builder/app/routes/trpc.$.ts +++ b/apps/builder/app/routes/trpc.$.ts @@ -1,17 +1,10 @@ // eslint-disable-next-line import/no-internal-modules import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; import type { ActionFunctionArgs } from "@remix-run/server-runtime"; -import { findAuthenticatedUser } from "~/services/auth.server"; import { createContext } from "~/shared/context.server"; import { appRouter } from "~/services/trcp-router.server"; export const action = async ({ request }: ActionFunctionArgs) => { - const authenticatedUser = await findAuthenticatedUser(request); - - if (authenticatedUser === null) { - throw new Error("Not authenticated"); - } - // https://trpc.io/docs/server/adapters/fetch const response = await fetchRequestHandler({ req: request,