From 43ecb0640c085971a77f243d72b9d62d961feecd Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 18 Nov 2024 19:34:30 -0800 Subject: refactor(authorised): move authorised user functionality to module --- src/routes/api/badges/+server.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/routes/api') diff --git a/src/routes/api/badges/+server.ts b/src/routes/api/badges/+server.ts index 7c62285d..9d5cb9a0 100644 --- a/src/routes/api/badges/+server.ts +++ b/src/routes/api/badges/+server.ts @@ -11,7 +11,7 @@ import { setShadowHiddenBadge, incrementClickCount } from '$lib/Database/SB/User/badges'; -import authorisedJson from '$lib/Data/Static/authorised.json'; +import privilegedUser from '$lib/Utility/privilegedUser'; const unauthorised = new Response('Unauthorised', { status: 401 }); @@ -66,7 +66,7 @@ export const PUT = async ({ cookies, url, request }) => { accessToken: user['access_token'], refreshToken: user['refresh_token'] }); - const authorised = authorisedJson.includes(identity.id); + const authorised = privilegedUser(identity.id); if (url.searchParams.get('shadowHide')) setShadowHidden(Number(url.searchParams.get('shadowHide')), authorised); @@ -100,9 +100,9 @@ export const PUT = async ({ cookies, url, request }) => { allBadges .filter((badge) => badge.category === (url.searchParams.get('category') || '')) .filter((badge) => badge.hidden).length > - allBadges.filter( - (badge) => badge.category === (url.searchParams.get('category') || '') - ).length / + allBadges.filter( + (badge) => badge.category === (url.searchParams.get('category') || '') + ).length / 2 ? false : true -- cgit v1.2.3