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
This commit is contained in:
Ivan Starkov authored and GitHub committed 2024-05-08 23:29:13 +03:00
1 parent e806bcbf5c
commit 29abc47820
1 file changed
-7
-7
View File
@@ -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,