Input sanitation. Minimum amount fix. Debug log updated.

This commit is contained in:
softsimon
2020-10-13 19:54:47 +07:00
parent 94e06a3a6b
commit 372c116283
3 changed files with 14 additions and 4 deletions

View File

@@ -118,11 +118,21 @@ class Routes {
return;
}
if (p.orderId !== '' && !/^(@|)[a-zA-Z0-9_]{1,15}$/.test(p.orderId)) {
res.status(400).send('Invalid Twitter handle');
return;
}
if (p.amount < 0.001) {
res.status(400).send('Amount needs to be at least 0.001');
return;
}
if (p.amount > 1000) {
res.status(400).send('Amount too large');
return;
}
try {
const result = await donations.createRequest(p.amount, p.orderId);
res.json(result);