From a227055c1eb09de79304acd39d6413c8bc3d4329 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Fri, 27 Jun 2025 21:31:39 +0300 Subject: [PATCH] validate prestige --- website/src/routes/api/prestige/+server.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/website/src/routes/api/prestige/+server.ts b/website/src/routes/api/prestige/+server.ts index 16b3261..4564278 100644 --- a/website/src/routes/api/prestige/+server.ts +++ b/website/src/routes/api/prestige/+server.ts @@ -34,6 +34,11 @@ export const POST: RequestHandler = async ({ request, locals }) => { throw error(400, 'Maximum prestige level reached'); } + const currentCashBalance = Number(userData.baseCurrencyBalance); + if (currentCashBalance < prestigeCost) { + throw error(400, `Insufficient cash funds for prestige. Need ${formatValue(prestigeCost)} cash, have ${formatValue(currentCashBalance)} cash. Coin holdings cannot be used for prestige costs.`); + } + const holdings = await tx .select({ coinId: userPortfolio.coinId, @@ -72,11 +77,6 @@ export const POST: RequestHandler = async ({ request, locals }) => { .where(eq(userPortfolio.userId, userId)); } - const currentBalance = Number(userData.baseCurrencyBalance) + totalSaleValue; - if (currentBalance < prestigeCost) { - throw error(400, `Insufficient funds. Need ${formatValue(prestigeCost)}, have ${formatValue(currentBalance)}`); - } - await tx .update(user) .set({