Skip to content

Commit

Permalink
Consolidate Complete views (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad authored Sep 22, 2023
1 parent 05cdf76 commit 637a7db
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 288 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@page "/sign-in/complete"
@using static OpenIddict.Abstractions.OpenIddictConstants
@inject IConfiguration Configuration
@model TeacherIdentity.AuthServer.Pages.SignIn.CompleteModel
@{
ViewBag.Title = Model.FirstTimeSignInForEmail ?
"You’ve created a DfE Identity account" :
ViewBag.Title = !Model.CanAccessService ? "You cannot access this service yet" :
Model.FirstTimeSignInForEmail ? "You’ve created a DfE Identity account" :
"You’ve signed in to your DfE Identity account";

var responseMode = Model.ResponseMode!;
Expand All @@ -21,9 +22,94 @@
}
}

ViewData.Add("Scope", Model.Scope);

var signOutLink = LinkGenerator.SignOut();

async Task RenderContent()
{
<govuk-panel class="app-panel--interruption">
<govuk-panel-title>@ViewBag.Title</govuk-panel-title>

<govuk-panel-body>
@if (Model.TrnRequirementType == TrnRequirementType.Required)
{
if (Model.TrnLookupStatus == TrnLookupStatus.Found)
{
if (Model.FirstTimeSignInForEmail)
{
<p>Weve found your details in our records and linked them to your DfE Identity account.</p>
<p>Next time, you can sign in just using your email @Model.Email.</p>
}
<p>Continue to <strong>@Model.ClientDisplayName</strong></p>
}
else if (Model.TrnLookupStatus == TrnLookupStatus.Pending)
{
if (Model.TrnLookupSupportTicketCreated)
{
<p>We need to do some more checks to see if your details are in our records.</p>
<p>Well email you when weve completed those checks - we may need some more information.</p>

<h2 class="govuk-heading-s">Your DfE Identity account</h2>
@if (Model.FirstTimeSignInForEmail)
{
<p>Youve created a DfE Identity account. To sign in to this service in the future, youll just need your email address @Model.Email.</p>
}
else
{
<p>Youve signed in to your DfE Identity account</p>
}
}
else
{
<p>We need to find your details in our records so you can use this service.</p>
<p>To fix this problem, please email our support team @(Configuration["SupportEmail"])</p>
}
}
else
{
<p>This could be because you do not have teaching qualifications, for example, qualified teacher status (QTS).</p>

<h2 class="govuk-heading-s">Your DfE Identity account</h2>
@if (Model.FirstTimeSignInForEmail)
{
<p>Youve created a DfE Identity account. When youre eligible to use this service, you can sign in just using your email @Model.Email.</p>
}
else
{
<p>Youve signed in to your DfE Identity account. When youre eligible to use this service, you can sign in just using your email @Model.Email.</p>
}
}
}
else if (Model.TrnRequirementType == TrnRequirementType.Optional)
{
if (Model.FirstTimeSignInForEmail)
{
if (Model.TrnLookupStatus == TrnLookupStatus.Found)
{
<p>Weve found your details in our records and linked them to your DfE Identity account.</p>
}
else
{
<p>We could not find your details in our records. Our support staff may get in touch to ask for more information. This is so we can link your existing details to your DfE Identity account.</p>
}
<p>Next time, you can sign in just using your email @Model.Email.</p>
}

<p>Continue to <strong>@Model.ClientDisplayName</strong></p>
}
else
{
if (Model.FirstTimeSignInForEmail)
{
<p>Next time, you can sign in just using your email @Model.Email.</p>
}

<p>Continue to <strong>@Model.ClientDisplayName</strong></p>
}

<govuk-button type="submit" class="app-button--inverse govuk-!-margin-bottom-0">Continue</govuk-button>
</govuk-panel-body>
</govuk-panel>
}
}

@section HeaderNav {
Expand All @@ -37,14 +123,7 @@
</nav>
}

@if (Model.TrnRequirementType == TrnRequirementType.Required && Model.TrnLookupStatus != TrnLookupStatus.Found)
{
<vc:sign-in-complete
trn-requirement-type="@Model.TrnRequirementType"
trn-lookup-status="@Model.TrnLookupStatus"
trn-lookup-support-ticket-created="@Model.TrnLookupSupportTicketCreated" />
}
else
@if (Model.CanAccessService)
{
<form action="@action" method="@method" asp-antiforgery="false">
@if (responseMode != ResponseModes.Fragment)
Expand All @@ -55,9 +134,10 @@ else
}
}

<vc:sign-in-complete
trn-requirement-type="@Model.TrnRequirementType"
trn-lookup-status="@Model.TrnLookupStatus"
trn-lookup-support-ticket-created="@Model.TrnLookupSupportTicketCreated" />
@{ await RenderContent(); }
</form>
}
else
{
await RenderContent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ public CompleteModel(

public string? Email { get; set; }

public bool GotTrn { get; set; }

public bool FirstTimeSignInForEmail { get; set; }

public string? Name { get; set; }

public string? Trn { get; set; }

public string? RedirectUri { get; set; }
Expand All @@ -42,12 +38,6 @@ public CompleteModel(

public IEnumerable<KeyValuePair<string, string>>? ResponseParameters { get; set; }

public bool AlreadyCompleted { get; set; }

public UserType UserType { get; set; }

public string? Scope { get; set; }

public TrnLookupStatus? TrnLookupStatus { get; set; }

public TrnRequirementType? TrnRequirementType { get; set; }
Expand All @@ -56,6 +46,8 @@ public CompleteModel(

public bool TrnLookupSupportTicketCreated { get; set; }

public bool CanAccessService { get; set; }

public async Task OnGet()
{
var authenticationState = HttpContext.GetAuthenticationState();
Expand All @@ -64,14 +56,10 @@ public async Task OnGet()
RedirectUri = authenticationState.OAuthState.RedirectUri;
ResponseMode = authenticationState.OAuthState.AuthorizationResponseMode!;
ResponseParameters = authenticationState.OAuthState.AuthorizationResponseParameters!;
CanAccessService = authenticationState.OAuthState?.TrnRequirementType != Models.TrnRequirementType.Required || authenticationState.Trn is not null;
Email = authenticationState.EmailAddress;
GotTrn = authenticationState.Trn is not null;
FirstTimeSignInForEmail = authenticationState.FirstTimeSignInForEmail!.Value;
Name = $"{authenticationState.FirstName} {authenticationState.LastName}";
Trn = authenticationState.Trn;
AlreadyCompleted = authenticationState.HaveResumedCompletedJourney;
UserType = authenticationState.UserType!.Value;
Scope = authenticationState.OAuthState?.Scope;
TrnLookupStatus = authenticationState.TrnLookupStatus;
TrnRequirementType = authenticationState.OAuthState?.TrnRequirementType;

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 637a7db

Please sign in to comment.