mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-09 17:33:12 -05:00
fix: allow admin users to delete other household recipes (#5767)
Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
@@ -64,6 +64,12 @@ class RecipeService(RecipeServiceBase):
|
||||
raise exceptions.NoEntryFound("Recipe not found.")
|
||||
return recipe
|
||||
|
||||
def can_delete(self, recipe: Recipe) -> bool:
|
||||
if self.user.admin:
|
||||
return True
|
||||
else:
|
||||
return self.can_update(recipe)
|
||||
|
||||
def can_update(self, recipe: Recipe) -> bool:
|
||||
if recipe.settings is None:
|
||||
raise exceptions.UnexpectedNone("Recipe Settings is None")
|
||||
@@ -423,7 +429,7 @@ class RecipeService(RecipeServiceBase):
|
||||
def delete_one(self, slug_or_id: str | UUID) -> Recipe:
|
||||
recipe = self.get_one(slug_or_id)
|
||||
|
||||
if not self.can_update(recipe):
|
||||
if not self.can_delete(recipe):
|
||||
raise exceptions.PermissionDenied("You do not have permission to delete this recipe.")
|
||||
|
||||
data = self.group_recipes.delete(recipe.id, "id")
|
||||
|
||||
Reference in New Issue
Block a user