From 46d3463c220410a8db7d4d2f941f65d1621ff8d6 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 3 Mar 2026 08:57:37 -0800 Subject: refactor(effect): migrate api auth cookie decoding --- src/routes/api/preferences/pin/+server.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/routes/api/preferences/pin/+server.ts') diff --git a/src/routes/api/preferences/pin/+server.ts b/src/routes/api/preferences/pin/+server.ts index 15465113..045d0187 100644 --- a/src/routes/api/preferences/pin/+server.ts +++ b/src/routes/api/preferences/pin/+server.ts @@ -1,4 +1,5 @@ import { userIdentity } from "$lib/Data/AniList/identity"; +import { decodeAuthCookieOrThrow } from "$lib/Effect/authCookie"; import { toggleHololiveStreamPinning } from "$lib/Database/SB/User/preferences"; const unauthorised = new Response("Unauthorised", { status: 401 }); @@ -8,18 +9,11 @@ export const PUT = async ({ cookies, url }) => { if (!userCookie) return unauthorised; - const user = JSON.parse(userCookie); + const user = decodeAuthCookieOrThrow(userCookie); return Response.json( await toggleHololiveStreamPinning( - ( - await userIdentity({ - tokenType: user["token_type"], - expiresIn: user["expires_in"], - accessToken: user["access_token"], - refreshToken: user["refresh_token"], - }) - ).id, + (await userIdentity(user)).id, url.searchParams.get("stream") || "", ), { -- cgit v1.2.3