feat: disallow double lifetime buys
This commit is contained in:
@@ -60,10 +60,12 @@ export const routes = new Elysia()
|
||||
|
||||
const { plan, months, coin } = body;
|
||||
|
||||
// Validate plan
|
||||
// Validate plan — block duplicate lifetime
|
||||
if (plan === "lifetime") {
|
||||
const [acc] = await sql`SELECT plan FROM accounts WHERE id = ${accountId}`;
|
||||
if (acc.plan === "lifetime") { set.status = 400; return { error: "Already on lifetime plan" }; }
|
||||
const [acc] = await sql`SELECT plan, plan_stack FROM accounts WHERE id = ${accountId}`;
|
||||
const stack = typeof acc.plan_stack === "string" ? JSON.parse(acc.plan_stack) : (acc.plan_stack || []);
|
||||
const hasLifetime = acc.plan === "lifetime" || stack.some((s: any) => s.plan === "lifetime");
|
||||
if (hasLifetime) { set.status = 400; return { error: "You already have a lifetime plan" }; }
|
||||
}
|
||||
|
||||
// Validate coin
|
||||
|
||||
Reference in New Issue
Block a user