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:
2025-12-17 11:51:48 +01:00
parent 752f781f54
commit a55b51e504
2 changed files with 3 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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>