diff options
Diffstat (limited to 'src/routes/api/preferences/+server.ts')
| -rw-r--r-- | src/routes/api/preferences/+server.ts | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/routes/api/preferences/+server.ts b/src/routes/api/preferences/+server.ts index c46a3abf..0a30274b 100644 --- a/src/routes/api/preferences/+server.ts +++ b/src/routes/api/preferences/+server.ts @@ -1,4 +1,5 @@ import { userIdentity } from "$lib/Data/AniList/identity"; +import { decodeAuthCookieOrThrow } from "$lib/Effect/authCookie"; import { getUserPreferences, toggleHideMissingBadges, @@ -28,15 +29,8 @@ export const PUT = async ({ url, cookies, request }) => { if (!userCookie) return unauthorised; - const user = JSON.parse(userCookie); - const userId = ( - await userIdentity({ - tokenType: user["token_type"], - expiresIn: user["expires_in"], - accessToken: user["access_token"], - refreshToken: user["refresh_token"], - }) - ).id; + const user = decodeAuthCookieOrThrow(userCookie); + const userId = (await userIdentity(user)).id; if (url.searchParams.get("toggleHideMissingBadges") !== null) return Response.json(await toggleHideMissingBadges(userId), { |