Add AuthScopedFilter to set AddedWho via middleware
Introduce AuthScopedFilter to automatically set the AddedWho property on IAuthScoped commands using configuration, and register it globally for all controllers. Remove manual AddedWho assignment from ResultViewController. Make AddedWho nullable in AuthScope and IAuthScoped.
This commit is contained in:
@@ -43,8 +43,6 @@ public class ResultViewController(IMediator mediator, IConfiguration config) : C
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] CreateResultViewCommand command, CancellationToken cancel)
|
||||
{
|
||||
// TODO: add middleware
|
||||
command.Scope.AddedWho = config?["AddedWho"] ?? throw new InvalidOperationException("The required 'AddedWho' configuration is missing. Please contact a system administrator.");
|
||||
await mediator.Send(command, cancel);
|
||||
return CreatedAtAction(nameof(Get), new { actionId = command.ActionId }, command);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user