Skip to content
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

Fix missing confirm url on subsequent #946

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/Authentication/Controllers/RequestSystemUserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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>
Expand Down Expand Up @@ -91,10 +96,18 @@ public async Task<ActionResult<RequestSystemResponse>> CreateRequest([FromBody]
SystemId = createRequest.SystemId,
};

SystemUser? existing = await _systemUserRepository.GetSystemUserByExternalRequestId(externalRequestId);
if (existing is not null)
{
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)
{
response.Value.ConfirmUrl = CONFIRMURL1 + _generalSettings.HostName + CONFIRMURL2 + response.Value.Id;
return Ok(response.Value);
}

Expand Down
Loading
Loading