Set AddedWho from config in Create; make property mutable
Changed AuthScope.AddedWho to be mutable (get; set;). In ResultViewController, set AddedWho from configuration in the Create action and throw an error if missing. Ensures AddedWho is always set and configuration issues are clearly reported.
This commit is contained in:
@@ -43,6 +43,8 @@ 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);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace ReC.Application.Common.Interfaces;
|
||||
|
||||
public record AuthScope
|
||||
{
|
||||
public string AddedWho { get; } = null!;
|
||||
public string AddedWho { get; set; } = null!;
|
||||
}
|
||||
|
||||
public interface IAuthScoped : IScoped<AuthScope>
|
||||
|
||||
Reference in New Issue
Block a user