Skip to content

Commit

Permalink
Merge 3ee0421 into 2389055
Browse files Browse the repository at this point in the history
  • Loading branch information
acsauk authored Oct 3, 2024
2 parents 2389055 + 3ee0421 commit 48da166
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,26 @@ import (
)

type oneLoginIdentityDetailsData struct {
App appcontext.Data
Errors validation.List
CertificateProvider *certificateproviderdata.Provided
App appcontext.Data
Errors validation.List
Provided *certificateproviderdata.Provided
DonorFullName string
}

func OneLoginIdentityDetails(tmpl template.Template, certificateProviderStore CertificateProviderStore, lpaStoreResolvingService LpaStoreResolvingService) Handler {
return func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, certificateProvider *certificateproviderdata.Provided) error {
lpa, err := lpaStoreResolvingService.Get(r.Context())
if err != nil {
return err
}

data := &oneLoginIdentityDetailsData{
App: appData,
CertificateProvider: certificateProvider,
App: appData,
Provided: certificateProvider,
DonorFullName: lpa.Donor.FullName(),
}

if r.Method == http.MethodPost {
lpa, err := lpaStoreResolvingService.Get(r.Context())
if err != nil {
return err
}

if certificateProvider.CertificateProviderIdentityConfirmed(
lpa.CertificateProvider.FirstNames,
lpa.CertificateProvider.LastName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,25 @@ func TestGetOneLoginIdentityDetails(t *testing.T) {
LpaID: "lpa-id",
}

lpaResolvingService := newMockLpaStoreResolvingService(t)
lpaResolvingService.EXPECT().
Get(r.Context()).
Return(&lpadata.Lpa{
LpaUID: "lpa-uid",
CertificateProvider: lpadata.CertificateProvider{FirstNames: "a", LastName: "b"},
Donor: lpadata.Donor{FirstNames: "c", LastName: "d"},
}, nil)

template := newMockTemplate(t)
template.EXPECT().
Execute(w, &oneLoginIdentityDetailsData{
App: testAppData,
CertificateProvider: certificateProvider,
App: testAppData,
Provided: certificateProvider,
DonorFullName: "c d",
}).
Return(nil)

err := OneLoginIdentityDetails(template.Execute, nil, nil)(testAppData, w, r, certificateProvider)
err := OneLoginIdentityDetails(template.Execute, nil, lpaResolvingService)(testAppData, w, r, certificateProvider)
resp := w.Result()

assert.Nil(t, err)
Expand All @@ -43,12 +53,17 @@ func TestGetOneLoginIdentityDetailsWhenTemplateErrors(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/", nil)
w := httptest.NewRecorder()

lpaResolvingService := newMockLpaStoreResolvingService(t)
lpaResolvingService.EXPECT().
Get(mock.Anything).
Return(&lpadata.Lpa{}, nil)

template := newMockTemplate(t)
template.EXPECT().
Execute(mock.Anything, mock.Anything).
Return(expectedError)

err := OneLoginIdentityDetails(template.Execute, nil, nil)(testAppData, w, r, &certificateproviderdata.Provided{})
err := OneLoginIdentityDetails(template.Execute, nil, lpaResolvingService)(testAppData, w, r, &certificateproviderdata.Provided{})
resp := w.Result()

assert.Equal(t, expectedError, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/donor/donorpage/one_login_identity_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type oneLoginIdentityDetailsData struct {
App appcontext.Data
Errors validation.List
DonorProvided *donordata.Provided
Provided *donordata.Provided
FirstNamesMatch bool
LastNameMatch bool
DateOfBirthMatch bool
Expand All @@ -34,7 +34,7 @@ func OneLoginIdentityDetails(tmpl template.Template, donorStore DonorStore) Hand
data := &oneLoginIdentityDetailsData{
App: appData,
Form: form.NewYesNoForm(form.YesNoUnknown),
DonorProvided: provided,
Provided: provided,
DetailsUpdated: r.FormValue("detailsUpdated") == "1",
FirstNamesMatch: strings.EqualFold(provided.Donor.FirstNames, provided.IdentityUserData.FirstNames),
LastNameMatch: strings.EqualFold(provided.Donor.LastName, provided.IdentityUserData.LastName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestGetOneLoginIdentityDetails(t *testing.T) {
Execute(w, &oneLoginIdentityDetailsData{
App: testAppData,
Form: form.NewYesNoForm(form.YesNoUnknown),
DonorProvided: tc.donorProvided,
Provided: tc.donorProvided,
DetailsUpdated: tc.expectedDetailsUpdated,
FirstNamesMatch: tc.expectedFirstNamesMatch,
LastNameMatch: tc.expectedLastNameMatch,
Expand Down
6 changes: 4 additions & 2 deletions lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,6 @@
"theDetailsOnYourLPA": "Welsh",
"someDetailsDoNotMatchIdentityDetailsWarning": "Welsh",
"yourLPADetailsHaveBeenUpdatedToMatchIdentitySuccess": "Welsh",
"confirmedIdentityDetails": "Welsh",
"doesNotMatch": "Welsh",
"updateMyLPADetailsToMatchIdentityHint": "Welsh",
"iUnderstandThisWillWithdrawLPAHint": "Welsh",
Expand Down Expand Up @@ -1402,5 +1401,8 @@
"iConfirmTheLpaWasSignedInMyPresence": "Welsh",
"trustCorporationSignature": "Welsh",
"replacementTrustCorporationSignature": "Welsh",
"defaultDecisionHasBeenSelected": "Welsh"
"defaultDecisionHasBeenSelected": "Welsh",
"youHaveSuccessfullyConfirmedYourIdentitySuccess:donor": "<div class=\"govuk-notification-banner__content\"><h2 class=\"govuk-notification-banner__heading\">Welsh</h2><p class=\"govuk-body\">Welsh</p></div>",
"youHaveSuccessfullyConfirmedYourIdentitySuccess:certificate-provider": "<div class=\"govuk-notification-banner__content\"><h2 class=\"govuk-notification-banner__heading\">Welsh</h2><p class=\"govuk-body\">Welsh {{possessive .DonorFullName }} Welsh</p></div>",
"youHaveSuccessfullyConfirmedYourIdentitySuccess:voucher": "<div class=\"govuk-notification-banner__content\"><h2 class=\"govuk-notification-banner__heading\">Welsh</h2><p class=\"govuk-body\">Welsh</p></div>"
}
6 changes: 4 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@
"theDetailsOnYourLPA": "The details on your LPA",
"someDetailsDoNotMatchIdentityDetailsWarning": "Some of the details on your LPA do not match your confirmed identity details",
"yourLPADetailsHaveBeenUpdatedToMatchIdentitySuccess": "Your LPA details have been updated to match your confirmed identity",
"confirmedIdentityDetails": "Confirmed identity details",
"doesNotMatch": "Does not match",
"updateMyLPADetailsToMatchIdentityHint": "Update my LPA details to match my confirmed identity details.",
"iUnderstandThisWillWithdrawLPAHint": "I understand that this will withdraw my LPA and I will no longer be able to access it.",
Expand Down Expand Up @@ -1331,5 +1330,8 @@
"iConfirmTheLpaWasSignedInMyPresence": "I confirm that the LPA was signed in my presence and that my name and address are correct.",
"trustCorporationSignature": "Trust corporation signature",
"replacementTrustCorporationSignature": "Replacement trust corporation signature",
"defaultDecisionHasBeenSelected": "A default decision has been selected for you because your answer was missing or your intention unclear."
"defaultDecisionHasBeenSelected": "A default decision has been selected for you because your answer was missing or your intention unclear.",
"youHaveSuccessfullyConfirmedYourIdentitySuccess:donor": "<div class=\"govuk-notification-banner__content\"><h2 class=\"govuk-notification-banner__heading\">You have successfully confirmed your identity</h2><p class=\"govuk-body\">Thank you for confirming your identity using GOV.UK One Login. Your details match those you entered in your LPA.</p></div>",
"youHaveSuccessfullyConfirmedYourIdentitySuccess:certificate-provider": "<div class=\"govuk-notification-banner__content\"><h2 class=\"govuk-notification-banner__heading\">You have successfully confirmed your identity</h2><p class=\"govuk-body\">Thank you for confirming your identity using GOV.UK One Login. Your details match those entered in {{possessive .DonorFullName }} LPA.</p></div>",
"youHaveSuccessfullyConfirmedYourIdentitySuccess:voucher": "<div class=\"govuk-notification-banner__content\"><h2 class=\"govuk-notification-banner__heading\">You have successfully confirmed your identity</h2><p class=\"govuk-body\">Thank you for confirming your identity using GOV.UK One Login.</p></div>"
}
21 changes: 2 additions & 19 deletions web/template/certificateprovider/onelogin_identity_details.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,9 @@
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">{{ tr .App "yourIdentityConfirmedWithOneLogin" }}</h1>
{{ template "notification-banner" (notificationBanner .App "success" (trFormatHtml .App "youHaveSuccessfullyConfirmedYourIdentitySuccess:certificate-provider" "DonorFullName" .DonorFullName) "success" "contents" ) }}

<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">First Names</dt>
<dd class="govuk-summary-list__value">{{ .CertificateProvider.IdentityUserData.FirstNames }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Last Name</dt>
<dd class="govuk-summary-list__value">{{ .CertificateProvider.IdentityUserData.LastName }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Date of birth</dt>
<dd class="govuk-summary-list__value">{{ formatDate .App .CertificateProvider.IdentityUserData.DateOfBirth }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Confirmed at</dt>
<dd class="govuk-summary-list__value">{{ formatDateTime .App .CertificateProvider.IdentityUserData.RetrievedAt }}</dd>
</div>
</dl>
{{ template "identityDetails" . }}

<form novalidate method="post">
{{ template "buttons" (button .App "continue") }}
Expand Down
154 changes: 79 additions & 75 deletions web/template/donor/onelogin_identity_details.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,98 @@
{{ tr .App "yourConfirmedIdentityDetails" }}
{{ end }}

{{ define "main" }}
{{ $donor := .DonorProvided.Donor }}
{{ $userData := .DonorProvided.IdentityUserData }}
{{ $donorFullName := (printf "%s %s" $userData.FirstNames $userData.LastName) }}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ if not .DetailsMatch }}
{{ template "warning-banner" (content .App "someDetailsDoNotMatchIdentityDetailsWarning") }}
{{ else if .DetailsUpdated }}
{{ template "notification-banner" (notificationBanner .App "success" (trHtml .App "yourLPADetailsHaveBeenUpdatedToMatchIdentitySuccess") "success" "heading") }}
{{ end}}
{{ define "providedDetails" }}
<h1 class="govuk-heading-m">{{ tr .App "theDetailsOnYourLPA" }}</h1>

<h1 class="govuk-heading-m">{{ tr .App "theDetailsOnYourLPA" }}</h1>

<dl class="govuk-summary-list govuk-!-margin-bottom-9">
<div class="govuk-summary-list__row {{ if .FirstNamesMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "firstNames" }}</dt>
<dd class="govuk-summary-list__value">{{ $donor.FirstNames }}</dd>
{{ if not .FirstNamesMatch }}
<dd class="govuk-summary-list__actions"><span class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span></dd>
{{ end }}
<dl class="govuk-summary-list govuk-!-margin-bottom-9">
<div
class="govuk-summary-list__row {{ if .FirstNamesMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "firstNames" }}</dt>
<dd class="govuk-summary-list__value">{{ .Provided.Donor.FirstNames }}</dd>
{{ if not .FirstNamesMatch }}
<dd class="govuk-summary-list__actions"><span
class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span>
</dd>
{{ end }}
</div>
<div class="govuk-summary-list__row {{ if .LastNameMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "lastName" }}</dt>
<dd class="govuk-summary-list__value">{{ $donor.LastName }}</dd>
{{ if not .LastNameMatch }}
<dd class="govuk-summary-list__actions"><span class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span></dd>
{{ end}}
<div
class="govuk-summary-list__row {{ if .LastNameMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "lastName" }}</dt>
<dd class="govuk-summary-list__value">{{ .Provided.Donor.LastName }}</dd>
{{ if not .LastNameMatch }}
<dd class="govuk-summary-list__actions"><span
class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span>
</dd>
{{ end}}
</div>
<div class="govuk-summary-list__row {{ if .DateOfBirthMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "dateOfBirth" }}</dt>
<dd class="govuk-summary-list__value">{{ (formatDate .App $donor.DateOfBirth) }}</dd>
{{ if not .DateOfBirthMatch }}
<dd class="govuk-summary-list__actions"><span class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span></dd>
{{ end}}
<div
class="govuk-summary-list__row {{ if .DateOfBirthMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "dateOfBirth" }}</dt>
<dd class="govuk-summary-list__value">{{ (formatDate .App .Provided.Donor.DateOfBirth) }}</dd>
{{ if not .DateOfBirthMatch }}
<dd class="govuk-summary-list__actions"><span
class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span>
</dd>
{{ end}}
</div>
<div class="govuk-summary-list__row {{ if .AddressMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "address" }}</dt>
<dd class="govuk-summary-list__value">{{ template "address-lines" $donor.Address }}</dd>
{{ if not .AddressMatch }}
<dd class="govuk-summary-list__actions"><span class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span></dd>
{{ end }}
<div
class="govuk-summary-list__row {{ if .AddressMatch }}govuk-summary-list__row--no-actions{{end}}">
<dt class="govuk-summary-list__key">{{ tr .App "address" }}</dt>
<dd class="govuk-summary-list__value">{{ template "address-lines" .Provided.Donor.Address }}</dd>
{{ if not .AddressMatch }}
<dd class="govuk-summary-list__actions"><span
class="moj-badge moj-badge--red app-08rem-font-size">{{ tr .App "doesNotMatch" }}</span>
</dd>
{{ end }}
</div>
</dl>
</dl>
{{ end }}

<div class="govuk-summary-card">
<div class="govuk-summary-card__title-wrapper">
<h2 class="govuk-summary-card__title">{{ tr .App "confirmedIdentityDetails" }}</h2>
</div>
<div class="govuk-summary-card__content">
<dl class="govuk-summary-list">
{{ template "summary-row" (summaryRow .App "firstNames" $userData.FirstNames "" $donorFullName false true ) }}
{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ if .DetailsUpdated }}
{{ template "notification-banner" (notificationBanner .App "success" (trHtml .App "yourLPADetailsHaveBeenUpdatedToMatchIdentitySuccess") "success" "heading") }}

{{ template "summary-row" (summaryRow .App "lastName" $userData.LastName "" $donorFullName false true ) }}
{{ template "providedDetails" . }}
{{ template "identityDetails" . }}
{{ else if .DetailsMatch }}
{{ template "notification-banner" (notificationBanner .App "success" (trHtml .App "youHaveSuccessfullyConfirmedYourIdentitySuccess:donor") "success" "contents" ) }}

{{ template "summary-row" (summaryRow .App "dateOfBirth" (formatDate .App $userData.DateOfBirth) "" $donorFullName false true ) }}
{{ template "identityDetails" . }}
{{ else if not .DetailsMatch }}
{{ template "warning-banner" (content .App "someDetailsDoNotMatchIdentityDetailsWarning") }}

{{ template "address-summary-row" (summaryRow $.App "address" $userData.CurrentAddress "" $donorFullName false true ) }}
</dl>
</div>
</div>
{{ template "providedDetails" . }}
{{ template "identityDetails" . }}
{{ end}}

<form novalidate method="post">
{{ if not .DetailsMatch }}
{{ template "warning" (content .App "youCanOnlyContinueIfDetailsMatchWarning") }}
<form novalidate method="post">
{{ if not .DetailsMatch }}
{{ template "warning" (content .App "youCanOnlyContinueIfDetailsMatchWarning") }}

<div class="govuk-form-group {{ if .Errors.Has .Form.FieldName }}govuk-form-group--error{{ end }}">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--m">{{ tr .App "wouldYouLikeToUpdateDetailsToMatchIdentityDetails" }}</legend>
<div class="govuk-form-group {{ if .Errors.Has .Form.FieldName }}govuk-form-group--error{{ end }}">
<fieldset class="govuk-fieldset">
<legend
class="govuk-fieldset__legend govuk-fieldset__legend--m">{{ tr .App "wouldYouLikeToUpdateDetailsToMatchIdentityDetails" }}</legend>

{{ template "error-message" (errorMessage . .Form.FieldName) }}
{{ template "error-message" (errorMessage . .Form.FieldName) }}

{{ template "radios" (items . .Form.FieldName .Form.YesNo.String
(item .Form.Options.Yes.String "yes" "hint" "updateMyLPADetailsToMatchIdentityHint")
(item .Form.Options.No.String "no" "hint" "iUnderstandThisWillWithdrawLPAHint")
) }}
</fieldset>
</div>
{{ end }}
{{ template "radios" (items . .Form.FieldName .Form.YesNo.String
(item .Form.Options.Yes.String "yes" "hint" "updateMyLPADetailsToMatchIdentityHint")
(item .Form.Options.No.String "no" "hint" "iUnderstandThisWillWithdrawLPAHint")
) }}
</fieldset>
</div>
{{ end }}

{{ if not .DetailsUpdated }}
{{ template "buttons" (button .App "continue") }}
{{ else }}
{{ template "continue-button" . }}
{{ end }}
{{ template "csrf-field" . }}
</form>
{{ if not .DetailsUpdated }}
{{ template "buttons" (button .App "continue") }}
{{ else }}
{{ template "continue-button" . }}
{{ end }}
{{ template "csrf-field" . }}
</form>
</div>
</div>
</div>
{{ end }}
Loading

0 comments on commit 48da166

Please sign in to comment.