diff --git a/src/routes/admin/api/transactions.js b/src/routes/admin/api/transactions.js index 540b705c0dc0d745cd9ac7609b721604ff4d6568..4d8be78c77d9de1aa3d8f7660aa1603019a4a2f7 100644 --- a/src/routes/admin/api/transactions.js +++ b/src/routes/admin/api/transactions.js @@ -109,7 +109,8 @@ export async function editVoucher(id, code, amount, activated, expiresAt){ }); } -function generateRandomString(forbidden=new Set(), length=14, chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){ +// >33k codes needed for a 1% chance of a collision +function generateRandomString(forbidden=new Set(), length=6, chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){ let result = ""; for(let i = 0; i < length; i++){ result += chars.charAt(Math.floor(Math.random() * chars.length));