mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 18:14:44 +00:00
Enforce brewery ownership on update and delete (#267)
This commit is contained in:
@@ -10,8 +10,17 @@ public class DeleteBreweryHandler(IBreweryRepository repository)
|
||||
/// <exception cref="Domain.Exceptions.NotFoundException">
|
||||
/// Thrown when no brewery exists with <paramref name="request" />'s <c>BreweryPostId</c>.
|
||||
/// </exception>
|
||||
public Task Handle(DeleteBreweryCommand request, CancellationToken cancellationToken)
|
||||
/// <exception cref="Domain.Exceptions.ForbiddenException">
|
||||
/// Thrown when <paramref name="request" />'s <c>RequestingUserId</c> did not post the brewery.
|
||||
/// </exception>
|
||||
public async Task Handle(DeleteBreweryCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
return repository.DeleteAsync(request.BreweryPostId);
|
||||
await repository.EnsureCallerOwnsBreweryAsync(
|
||||
request.BreweryPostId,
|
||||
request.RequestingUserId,
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
await repository.DeleteAsync(request.BreweryPostId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user