Skip to content

Commit 59213a3

Browse files
committed
fix being able to request private levels
1 parent 41d83a0 commit 59213a3

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

backend/server.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ const server = Bun.serve({
407407
if (levelId) {
408408
const level =
409409
await sql`select id, public, data, name, width, height, owner, tags, image_url, approvals, disapprovals, approval_percentage, total_plays, finished_plays, description, level_style from levels where id = ${levelId} limit 1`;
410+
411+
410412
if (!level[0] || level.length === 0) {
411413
return new Response(
412414
JSON.stringify({ error: "Level not found" }),
@@ -417,6 +419,13 @@ const server = Bun.serve({
417419
);
418420
}
419421

422+
if (!level[0].public) {
423+
return new Response(
424+
"Level is private",
425+
{ status: 401 }
426+
)
427+
}
428+
420429
const returnedJson = level[0];
421430
returnedJson.owned =
422431
returnedJson.owner == authentication?.user || false;

0 commit comments

Comments
 (0)