From 1c4d93e3b204d94dcc3234e3d99d6e570b33ff0b Mon Sep 17 00:00:00 2001 From: James Gunn Date: Mon, 25 Sep 2023 12:42:20 +0100 Subject: [PATCH] Align Landing page and No Account page for Strict TRN lookup (#727) --- .../Pages/SignIn/Landing.cshtml | 6 ++-- .../Pages/SignIn/Landing.cshtml.cs | 5 +-- .../Pages/SignIn/Register/NoAccount.cshtml | 16 ++++++++- .../Pages/SignIn/Register/NoAccount.cshtml.cs | 35 ++++++------------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml index a3034cb5a..43041a319 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml @@ -26,8 +26,10 @@
  • teacher reference number (TRN)
  • } - -

    Once you’ve created an account, you can continue to @Model.ClientDisplayName.

    + else + { +

    Once you’ve created an account, you can continue to @Model.ClientDisplayName.

    + } } diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml.cs b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml.cs index 83db67941..2df8db69f 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml.cs +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Landing.cshtml.cs @@ -1,4 +1,3 @@ -using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.RazorPages; using TeacherIdentity.AuthServer.Journeys; using TeacherIdentity.AuthServer.Models; @@ -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); } } diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml index 1fc1241a0..328650398 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml @@ -28,7 +28,21 @@
  • name and date of birth
  • -

    Once you’ve created an account, you can continue to @Model.ClientDisplayName.

    + @if (Model.ClientDisplayName is not null) + { + @if (Model.TrnMatchPolicy == TrnMatchPolicy.Strict) + { +

    To use your DfE Identity account to @Model.ClientDisplayName, you’ll also need your:

    + + } + else + { +

    Once you’ve created an account, you can continue to @Model.ClientDisplayName.

    + } + } Create an account diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml.cs b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml.cs index d90e0e1e8..5aaab2530 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml.cs +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Register/NoAccount.cshtml.cs @@ -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; @@ -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 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(); - } }