feat: Neue Update-Methode in GroupService hinzugefügt mit Validierung für Systemgruppen
This commit is contained in:
parent
733cb967cb
commit
ca214225ea
@ -5,6 +5,8 @@ using DigitalData.UserManager.Domain.Entities;
|
||||
using DigitalData.UserManager.Application.Contracts.Repositories;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using DigitalData.Core.Exceptions;
|
||||
|
||||
namespace DigitalData.UserManager.Application.Services
|
||||
{
|
||||
@ -34,5 +36,16 @@ namespace DigitalData.UserManager.Application.Services
|
||||
else
|
||||
return Result.Success(createdGroup.Id);
|
||||
}
|
||||
|
||||
public async override Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto)
|
||||
{
|
||||
var gId = updateDto.GetId<int>();
|
||||
var group = await _repository.ReadByIdAsync(gId);
|
||||
if (group is null)
|
||||
throw new ForbiddenException("Group not found.");
|
||||
else if (!group.Internal)
|
||||
throw new ForbiddenException("Updates are not allowed for system groups.");
|
||||
return await base.UpdateAsync(updateDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user