Bug: non-admin users cannot share a meal plan (user list is admin-only) #46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Non-admin users cannot share a meal plan. The user dropdown in the share dialog stays empty.
Cause
MealPlanShareDialogloads its user list viafetchAllUsers()(src/api/endpoints/UserRestResource.ts), which callsGET /user/all. The backend restricts that endpoint to administrators (requireAdmininUserResource). For every other role the call returns 403; the dialog only logs the error to the console (Fehler beim Laden der Benutzer) and shows no options.Fix direction
Spec 001 (shopping lists) introduces a user directory endpoint that any authenticated user may call (
POST /user/list-shareable, returning a reduced user summary without email or role). Once that endpoint exists, switch the meal plan share dialog to it.GET /user/allstays admin-only.Found during the cross-cutting architecture discussion of spec 001.
Addendum: replace the full
UserDtoin meal plan sharesMealPlanShareDto.sharedWithUsercurrently carries the fullUserDto, including email and role. Every user a plan is shared with can therefore see the email address of every other recipient.Spec 001 introduces
CompactUserDto(id, user name, first and last name, avatar; no email, no role) and makes it the convention for any DTO that exposes another user (seedocs/api-conventions.md, "Other users are exposed as CompactUserDto").As part of this fix, switch
MealPlanShareDto.sharedWithUserfromUserDtotoCompactUserDto. This is a contract change (api-contract/src/meal-plans.ts) that affects recipe-backend and recipe-app.Update:
list-shareableis a GETDuring the review of PR #20 the new route became
GET /user/list-shareable(reads without a body use GET,docs/adr/2026-09-30-get-reads-and-shallow-nesting.md), notPOSTas written above. The meal plan share routes themselves (DELETE /meal-plan/:id/share/:shareId,POST /meal-plan/:id/share/save-or-update) also break the new shallow-nesting rule; they are listed in recipe-platform#23 and can move together with this fix.