fix: remove broken bonus validation and require positive integer

dangling `if (Number(amount))` was a no-op, removed it and
tightened the check to reject negative/decimal/infinite values
This commit is contained in:
End Nightshade 2026-02-16 19:00:38 -07:00
parent 3a31660c38
commit fb5b019cac
No known key found for this signature in database

View file

@ -313,12 +313,10 @@ admin.post('/users/:id/bonus', async ({ params, body, headers, status }) => {
const { amount, reason } = body as { amount: number; reason: string }
if (!amount || typeof amount !== 'number') {
return status(400, { error: 'Amount is required and must be a number' })
if (!amount || typeof amount !== 'number' || !Number.isFinite(amount) || !Number.isInteger(amount) || amount <= 0) {
return status(400, { error: 'Amount is required and must be a positive integer' })
}
if (Number(amount))
if (!reason || typeof reason !== 'string' || reason.trim().length === 0) {
return status(400, { error: 'Reason is required' })
}