From 6559381ed4c54297bbc5cd57f8c9a0bebf4e1cb0 Mon Sep 17 00:00:00 2001 From: static Date: Wed, 8 Jan 2025 22:46:34 +0900 Subject: [PATCH] =?UTF-8?q?RequestHandler=20=ED=83=80=EC=9E=85=EC=9D=84=20?= =?UTF-8?q?=EC=9E=98=EB=AA=BB=EB=90=9C=20=EB=AA=A8=EB=93=88=EC=97=90?= =?UTF-8?q?=EC=84=9C=20import=ED=95=98=EB=8D=98=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/api/client/list/+server.ts | 10 +++++++--- src/routes/api/client/status/+server.ts | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/routes/api/client/list/+server.ts b/src/routes/api/client/list/+server.ts index 47fa5ab..5354ece 100644 --- a/src/routes/api/client/list/+server.ts +++ b/src/routes/api/client/list/+server.ts @@ -1,11 +1,15 @@ -import { json } from "@sveltejs/kit"; +import { error, json } from "@sveltejs/kit"; import { authenticate } from "$lib/server/modules/auth"; import { clientListResponse, type ClientListResponse } from "$lib/server/schemas"; import { getUserClientList } from "$lib/server/services/client"; -import type { RequestHandler } from "@sveltejs/kit"; +import type { RequestHandler } from "./$types"; export const GET: RequestHandler = async ({ cookies }) => { - const { userId } = authenticate(cookies); + const { userId, clientId } = authenticate(cookies); + if (!clientId) { + error(403, "Forbidden"); + } + const { userClients } = await getUserClientList(userId); return json(clientListResponse.parse({ clients: userClients } satisfies ClientListResponse)); }; diff --git a/src/routes/api/client/status/+server.ts b/src/routes/api/client/status/+server.ts index 3b413b7..a1e9cd8 100644 --- a/src/routes/api/client/status/+server.ts +++ b/src/routes/api/client/status/+server.ts @@ -2,7 +2,7 @@ import { error, json } from "@sveltejs/kit"; import { authenticate } from "$lib/server/modules/auth"; import { clientStatusResponse, type ClientStatusResponse } from "$lib/server/schemas"; import { getUserClientStatus } from "$lib/server/services/client"; -import type { RequestHandler } from "@sveltejs/kit"; +import type { RequestHandler } from "./$types"; export const GET: RequestHandler = async ({ cookies }) => { const { userId, clientId } = authenticate(cookies);