mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
Enforce brewery ownership on update and delete (#267)
This commit is contained in:
@@ -26,13 +26,18 @@ public class UpdateBreweryHandler(IBreweryRepository repository)
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
await repository.EnsureCallerOwnsBreweryAsync(
|
||||
request.BreweryPostId,
|
||||
request.RequestingUserId,
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
BreweryPost entity = new()
|
||||
{
|
||||
BreweryPostId = request.BreweryPostId,
|
||||
PostedById = request.PostedById,
|
||||
RowVersion = request.RowVersion,
|
||||
BreweryName = request.BreweryName,
|
||||
Description = request.Description,
|
||||
RowVersion = request.RowVersion,
|
||||
UpdatedAt = DateTime.UtcNow,
|
||||
Location = request.Location is null
|
||||
? null
|
||||
@@ -48,7 +53,7 @@ public class UpdateBreweryHandler(IBreweryRepository repository)
|
||||
},
|
||||
};
|
||||
|
||||
BreweryPost updated = await repository.UpdateAsync(entity);
|
||||
BreweryPost updated = await repository.UpdateAsync(entity, cancellationToken);
|
||||
return updated.ToDto();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user