fix: count only the current user's sandboxes towards the limit

This commit is contained in:
Akhilesh Rangani 2024-06-16 19:53:02 -04:00 committed by James Murdza
parent 9ec59bc781
commit 97c8598717

View File

@ -110,8 +110,13 @@ export default {
const body = await request.json()
const { type, name, userId, visibility } = initSchema.parse(body)
const allSandboxes = await db.select().from(sandbox).all()
if (allSandboxes.length >= 8) {
const userSandboxes = await db
.select()
.from(sandbox)
.where(eq(sandbox.userId, userId))
.all()
if (userSandboxes.length >= 8) {
return new Response("You reached the maximum # of sandboxes.", {
status: 400,
})