Skip to content

Commit

Permalink
Align Landing page and No Account page for Strict TRN lookup (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Sep 25, 2023
1 parent 637a7db commit 1c4d93e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
<li>teacher reference number (TRN)</li>
</ul>
}

<p>Once youve created an account, you can continue to <strong>@Model.ClientDisplayName</strong>.</p>
else
{
<p>Once youve created an account, you can continue to <strong>@Model.ClientDisplayName</strong>.</p>
}
}

<govuk-details>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.RazorPages;
using TeacherIdentity.AuthServer.Journeys;
using TeacherIdentity.AuthServer.Models;
Expand Down Expand Up @@ -26,12 +25,10 @@ public Landing(

public TrnMatchPolicy? TrnMatchPolicy { get; set; }

public async override Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next)
public async Task OnGet()
{
ClientDisplayName = (await _currentClientProvider.GetCurrentClient())?.DisplayName;

TrnMatchPolicy = _journey.AuthenticationState.OAuthState?.TrnMatchPolicy;

await base.OnPageHandlerExecutionAsync(context, next);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,21 @@
<li>name and date of birth</li>
</ul>

<p>Once you’ve created an account, you can continue to <strong>@Model.ClientDisplayName</strong>.</p>
@if (Model.ClientDisplayName is not null)
{
@if (Model.TrnMatchPolicy == TrnMatchPolicy.Strict)
{
<p>To use your DfE Identity account to @Model.ClientDisplayName, youll also need your:</p>
<ul class="govuk-list govuk-list--bullet">
<li>National Insurance number</li>
<li>teacher reference number (TRN)</li>
</ul>
}
else
{
<p>Once youve created an account, you can continue to <strong>@Model.ClientDisplayName</strong>.</p>
}
}

<govuk-button type="submit" class="app-button--inverse govuk-!-margin-bottom-0">Create an account</govuk-button>
</form>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.RazorPages;
using TeacherIdentity.AuthServer.Journeys;
using TeacherIdentity.AuthServer.Models;
using TeacherIdentity.AuthServer.Oidc;

namespace TeacherIdentity.AuthServer.Pages.SignIn.Register;
Expand All @@ -13,44 +13,31 @@ public class NoAccount : PageModel
private const string CurrentStep = CoreSignInJourney.Steps.NoAccount;

private readonly SignInJourney _journey;
private readonly TeacherIdentityApplicationManager _applicationManager;
private readonly ICurrentClientProvider _currentClientProvider;

public NoAccount(SignInJourney journey, TeacherIdentityApplicationManager applicationManager)
public NoAccount(SignInJourney journey, ICurrentClientProvider currentClientProvider)
{
_journey = journey;
_applicationManager = applicationManager;
_currentClientProvider = currentClientProvider;
}

public string? BackLink => _journey.TryGetPreviousStepUrl(CurrentStep, out var backLink) ? backLink : null;

public string? EmailAddress => _journey.AuthenticationState.EmailAddress;

public string? ClientDisplayName;
public string? ClientDisplayName { get; set; }

public void OnGet()
public TrnMatchPolicy? TrnMatchPolicy { get; set; }

public async Task OnGet()
{
ClientDisplayName = (await _currentClientProvider.GetCurrentClient())?.DisplayName;

TrnMatchPolicy = _journey.AuthenticationState.OAuthState?.TrnMatchPolicy;
}

public async Task<IActionResult> OnPost()
{
return await _journey.Advance(CurrentStep);
}

public override async Task OnPageHandlerExecutionAsync(PageHandlerExecutingContext context, PageHandlerExecutionDelegate next)
{
var clientId = _journey.AuthenticationState.OAuthState?.ClientId ??
HttpContext.GetClientRedirectInfo()?.ClientId;

if (clientId is not null)
{
var client = await _applicationManager.FindByClientIdAsync(clientId);
ClientDisplayName = await _applicationManager.GetDisplayNameAsync(client!);
}
else
{
ClientDisplayName ??= "DfE Identity account";
}

await next();
}
}

0 comments on commit 1c4d93e

Please sign in to comment.