Skip to content

Commit c893975

Browse files
jonkjetiloyeJon Kjetil Øye
andauthored
bug: add call to Altinn 2 ClearReporteeRights on delegation of accesspackage (#1745)
* bug: add call to Altinn 2 ClearReporteeRights on delegation of accesspackage #1743 * - added cache clearing on revoke of rightholder assignment --------- Co-authored-by: Jon Kjetil Øye <acn-joye@ai-dev.no>
1 parent 313bfe0 commit c893975

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/apps/Altinn.AccessManagement/src/Altinn.AccessMgmt.Core/Services/ConnectionService.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics;
2+
using Altinn.AccessManagement.Core.Clients.Interfaces;
23
using Altinn.AccessManagement.Core.Errors;
34
using Altinn.AccessMgmt.Core.Models;
45
using Altinn.AccessMgmt.Core.Services.Contracts;
@@ -22,7 +23,8 @@ namespace Altinn.AccessMgmt.Core.Services;
2223
public partial class ConnectionService(
2324
AppDbContext dbContext,
2425
ConnectionQuery connectionQuery,
25-
IAuditAccessor auditAccessor) : IConnectionService
26+
IAuditAccessor auditAccessor,
27+
IAltinn2RightsClient altinn2Client) : IConnectionService
2628
{
2729
public async Task<Result<IEnumerable<ConnectionDto>>> Get(Guid party, Guid? fromId, Guid? toId, Action<ConnectionOptions> configureConnections = null, CancellationToken cancellationToken = default)
2830
{
@@ -156,6 +158,12 @@ public async Task<ValidationProblemInstance> RemoveAssignment(Guid fromId, Guid
156158

157159
dbContext.Remove(existingAssignment);
158160
await dbContext.SaveChangesAsync(cancellationToken);
161+
162+
if (from.PartyId.HasValue && to.PartyId.HasValue)
163+
{
164+
await altinn2Client.ClearReporteeRights(from.PartyId.Value, to.PartyId.Value, to.UserId.HasValue ? to.UserId.Value : 0, cancellationToken: cancellationToken);
165+
}
166+
159167
return null;
160168
}
161169

@@ -346,6 +354,11 @@ private async Task<Result<AssignmentPackageDto>> AddPackage(Guid fromId, Guid to
346354
await dbContext.AssignmentPackages.AddAsync(newAssignmentPackage, cancellationToken);
347355
await dbContext.SaveChangesAsync(cancellationToken);
348356

357+
if (from.PartyId.HasValue && to.PartyId.HasValue)
358+
{
359+
await altinn2Client.ClearReporteeRights(from.PartyId.Value, to.PartyId.Value, to.UserId.HasValue ? to.UserId.Value : 0, cancellationToken: cancellationToken);
360+
}
361+
349362
return DtoMapper.Convert(newAssignmentPackage);
350363
}
351364

0 commit comments

Comments
 (0)