-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get system register dto fix not visible #939
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,14 @@ | |
using System.Security.Claims; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Altinn.Authentication.Core.Problems; | ||
using Altinn.Authorization.ProblemDetails; | ||
using Altinn.Platform.Authentication.Configuration; | ||
using Altinn.Platform.Authentication.Core.Constants; | ||
using Altinn.Platform.Authentication.Core.Models; | ||
using Altinn.Platform.Authentication.Core.Models.Parties; | ||
using Altinn.Platform.Authentication.Core.Models.SystemUsers; | ||
using Altinn.Platform.Authentication.Core.RepositoryInterfaces; | ||
using Altinn.Platform.Authentication.Helpers; | ||
using Altinn.Platform.Authentication.Model; | ||
using Altinn.Platform.Authentication.Services.Interfaces; | ||
|
@@ -34,16 +36,19 @@ public class RequestSystemUserController : ControllerBase | |
{ | ||
private readonly IRequestSystemUser _requestSystemUser; | ||
private readonly GeneralSettings _generalSettings; | ||
private readonly ISystemUserRepository _systemUserRepository; | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public RequestSystemUserController( | ||
IRequestSystemUser requestSystemUser, | ||
IOptions<GeneralSettings> generalSettings) | ||
IOptions<GeneralSettings> generalSettings, | ||
ISystemUserRepository systemUserRepository) | ||
{ | ||
_requestSystemUser = requestSystemUser; | ||
_generalSettings = generalSettings.Value; | ||
_systemUserRepository = systemUserRepository; | ||
} | ||
|
||
/// <summary> | ||
|
@@ -91,6 +96,13 @@ public async Task<ActionResult<RequestSystemResponse>> CreateRequest([FromBody] | |
SystemId = createRequest.SystemId, | ||
}; | ||
|
||
SystemUser? existing = await _systemUserRepository.GetSystemUserByExternalRequestId(externalRequestId); | ||
if (existing is not null) | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we follow a different error pattern in other controllers if i remember |
||
string message = $"SystemUser already exists with Id: {existing.Id}"; | ||
return Conflict(message); | ||
} | ||
|
||
// Check to see if the Request already exists | ||
Result<RequestSystemResponse> response = await _requestSystemUser.GetRequestByExternalRef(externalRequestId, vendorOrgNo); | ||
if (response.IsSuccess) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,11 @@ public async Task<ActionResult<List<RegisteredSystemDTO>>> GetListOfRegisteredSy | |
|
||
foreach (RegisteredSystem system in lista) | ||
{ | ||
if (!system.IsVisible) | ||
{ | ||
continue; | ||
} | ||
|
||
registeredSystemDTOs.Add(AuthenticationHelper.MapRegisteredSystemToRegisteredSystemDTO(system)); | ||
} | ||
|
||
|
@@ -68,7 +73,7 @@ public async Task<ActionResult<RegisteredSystemDTO>> GetRegisteredSystemDto(stri | |
{ | ||
RegisteredSystem registeredSystem = await _systemRegisterService.GetRegisteredSystemInfo(systemId, cancellationToken); | ||
|
||
if (registeredSystem == null) | ||
if (registeredSystem == null || !registeredSystem.IsVisible) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will break the bff and frontend? For vendorrequest and change request, in GET, the request only contains the systemId. The bff uses this service (authentication/api/v1/systemregister/{systemId}) to load the system (for displaying orgno, vendorname, systemname). An alternative solution for this is for backend to include the system object in GET vendorrequest and change request |
||
{ | ||
return NotFound(); | ||
} | ||
|
@@ -140,6 +145,12 @@ public async Task<ActionResult<SystemRegisterUpdateResult>> UpdateWholeRegistere | |
[HttpGet("{systemId}/rights")] | ||
public async Task<ActionResult<List<Right>>> GetRightsForRegisteredSystem(string systemId, CancellationToken cancellationToken = default) | ||
{ | ||
RegisteredSystem registerSystemResponse = await _systemRegisterService.GetRegisteredSystemInfo(systemId); | ||
if (registerSystemResponse == null || !registerSystemResponse.IsVisible) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
List<Right> lista = await _systemRegisterService.GetRightsForRegisteredSystem(systemId, cancellationToken); | ||
if (lista is null || lista.Count == 0) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we calling the repository directly? we usually route via the service