feat: scope every API endpoint to the token's sub; expose ownerId in DTOs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
// GET /api/lists/:id/tasks (web) — Idle tasks for a list. 404 if the list is unknown.
|
||||
// GET /api/lists/:id/tasks (web) — the caller's Idle tasks for a list. 404 if the list is unknown (to the caller).
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = getRouterParam(event, "id")!;
|
||||
const ownerId = ownerOf(event);
|
||||
const sql = getSql();
|
||||
if (!(await listExists(sql, id))) {
|
||||
if (!(await listExists(sql, ownerId, id))) {
|
||||
throw createError({ statusCode: 404, statusMessage: "list not found" });
|
||||
}
|
||||
const rows = await getTasksForList(sql, id);
|
||||
const rows = await getTasksForList(sql, ownerId, id);
|
||||
return rows.map(toTaskDto);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user