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

Consolidate Complete views #726

Merged
merged 1 commit into from
Sep 22, 2023
Merged
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
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>We’ve 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>We’ll email you when we’ve completed those checks - we may need some more information.</p>

<h2 class="govuk-heading-s">Your DfE Identity account</h2>
@if (Model.FirstTimeSignInForEmail)
{
<p>You’ve created a DfE Identity account. To sign in to this service in the future, you’ll just need your email address @Model.Email.</p>
}
else
{
<p>You’ve 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>You’ve created a DfE Identity account. When you’re eligible to use this service, you can sign in just using your email @Model.Email.</p>
}
else
{
<p>You’ve signed in to your DfE Identity account. When you’re 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>We’ve 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
Loading