diff --git a/internal/voucher/path.go b/internal/voucher/path.go index 9932e70172..7397008f9f 100644 --- a/internal/voucher/path.go +++ b/internal/voucher/path.go @@ -47,7 +47,7 @@ func (p Path) Redirect(w http.ResponseWriter, r *http.Request, appData appcontex func (p Path) CanGoTo(provided *voucherdata.Provided) bool { switch p { case PathYourName: - return !provided.Tasks.ConfirmYourIdentity.IsCompleted() + return provided.Tasks.ConfirmYourIdentity.IsNotStarted() case PathVerifyDonorDetails: return provided.Tasks.ConfirmYourName.IsCompleted() && diff --git a/internal/voucher/voucherpage/confirm_allowed_to_vouch.go b/internal/voucher/voucherpage/confirm_allowed_to_vouch.go index 7228bbc058..09dcfa4497 100644 --- a/internal/voucher/voucherpage/confirm_allowed_to_vouch.go +++ b/internal/voucher/voucherpage/confirm_allowed_to_vouch.go @@ -3,6 +3,7 @@ package voucherpage import ( "errors" "net/http" + "strings" "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" @@ -20,6 +21,7 @@ type confirmAllowedToVouchData struct { Form *form.YesNoForm Lpa *lpadata.Lpa SurnameMatchesDonor bool + MatchIdentity bool } func ConfirmAllowedToVouch(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, voucherStore VoucherStore) Handler { @@ -33,7 +35,8 @@ func ConfirmAllowedToVouch(tmpl template.Template, lpaStoreResolvingService LpaS App: appData, Form: form.NewYesNoForm(form.YesNoUnknown), Lpa: lpa, - SurnameMatchesDonor: provided.LastName == lpa.Donor.LastName, + SurnameMatchesDonor: strings.EqualFold(provided.LastName, lpa.Donor.LastName), + MatchIdentity: provided.Tasks.ConfirmYourIdentity.IsInProgress(), } if r.Method == http.MethodPost { @@ -45,7 +48,12 @@ func ConfirmAllowedToVouch(tmpl template.Template, lpaStoreResolvingService LpaS return errors.New("// TODO there should be a page here but it hasn't been built yet") } - provided.Tasks.ConfirmYourName = task.StateCompleted + if provided.Tasks.ConfirmYourIdentity.IsInProgress() { + provided.Tasks.ConfirmYourIdentity = task.StateCompleted + } else { + provided.Tasks.ConfirmYourName = task.StateCompleted + } + if err := voucherStore.Put(r.Context(), provided); err != nil { return err } diff --git a/internal/voucher/voucherpage/confirm_your_name.go b/internal/voucher/voucherpage/confirm_your_name.go index e7d43b6c71..fe8b9cbd2b 100644 --- a/internal/voucher/voucherpage/confirm_your_name.go +++ b/internal/voucher/voucherpage/confirm_your_name.go @@ -2,6 +2,7 @@ package voucherpage import ( "net/http" + "strings" "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" @@ -45,7 +46,8 @@ func ConfirmYourName(tmpl template.Template, lpaStoreResolvingService LpaStoreRe provided.FirstNames = firstNames provided.LastName = lastName - if lastName == lpa.Donor.LastName || !provided.NameMatches(lpa).IsNone() { + if !provided.Tasks.ConfirmYourName.IsCompleted() && + (strings.EqualFold(lastName, lpa.Donor.LastName) || !provided.NameMatches(lpa).IsNone()) { redirect = voucher.PathConfirmAllowedToVouch state = task.StateInProgress } diff --git a/internal/voucher/voucherpage/identity_with_one_login_callback.go b/internal/voucher/voucherpage/identity_with_one_login_callback.go index 143903309f..4bc49588a0 100644 --- a/internal/voucher/voucherpage/identity_with_one_login_callback.go +++ b/internal/voucher/voucherpage/identity_with_one_login_callback.go @@ -45,7 +45,12 @@ func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore Se } provided.IdentityUserData = userData - provided.Tasks.ConfirmYourIdentity = task.StateCompleted + if provided.NameMatches(lpa).IsNone() { + provided.Tasks.ConfirmYourIdentity = task.StateCompleted + } else { + provided.Tasks.ConfirmYourIdentity = task.StateInProgress + } + if err := voucherStore.Put(r.Context(), provided); err != nil { return err } @@ -66,6 +71,10 @@ func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore Se return voucher.PathUnableToConfirmIdentity.Redirect(w, r, appData, appData.LpaID) } - return voucher.PathOneLoginIdentityDetails.Redirect(w, r, appData, appData.LpaID) + if provided.Tasks.ConfirmYourIdentity.IsCompleted() { + return voucher.PathOneLoginIdentityDetails.Redirect(w, r, appData, appData.LpaID) + } + + return voucher.PathConfirmAllowedToVouch.Redirect(w, r, appData, appData.LpaID) } } diff --git a/internal/voucher/voucherpage/task_list.go b/internal/voucher/voucherpage/task_list.go index b14fb9d562..7a8bf96e8e 100644 --- a/internal/voucher/voucherpage/task_list.go +++ b/internal/voucher/voucherpage/task_list.go @@ -32,7 +32,10 @@ func TaskList(tmpl template.Template, lpaStoreResolvingService LpaStoreResolving } confirmYourIdentityPath := voucher.PathConfirmYourIdentity - if provided.Tasks.ConfirmYourIdentity.IsCompleted() { + switch provided.Tasks.ConfirmYourIdentity { + case task.StateInProgress: + confirmYourIdentityPath = voucher.PathConfirmAllowedToVouch + case task.StateCompleted: confirmYourIdentityPath = voucher.PathOneLoginIdentityDetails } diff --git a/lang/en.json b/lang/en.json index 3ff1db8624..712070c654 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1280,5 +1280,6 @@ "thankYou": "Thank you", "youHaveVouchedFor": "You have vouched for {{.DonorFullNamePossessive}} identity.", "voucherThankYouContent": "

You do not need to do anything else.

{{.DonorFirstNamesPossessive}} vouching request will no longer appear on your dashboard.

You can print this page out for your records if you wish, or close this browsing window.

", - "youHaveEnteredNameWhichMatchesSomeone": "You have entered a name that matches someone named on {{.DonorFullNamePossessive}} lasting power of attorney (LPA)." + "youHaveEnteredNameWhichMatchesSomeone": "You have entered a name that matches someone named on {{.DonorFullNamePossessive}} lasting power of attorney (LPA).", + "yourConfirmedIdentityDetailsMatchSomeone": "Your confirmed identity details match someone named on {{.DonorFullNamePossessive}} lasting power of attorney (LPA)." } diff --git a/web/template/voucher/confirm_allowed_to_vouch.gohtml b/web/template/voucher/confirm_allowed_to_vouch.gohtml index 78be805a02..7bbc9727b9 100644 --- a/web/template/voucher/confirm_allowed_to_vouch.gohtml +++ b/web/template/voucher/confirm_allowed_to_vouch.gohtml @@ -10,7 +10,10 @@

{{ tr .App "confirmThatYouAreAllowedToVouch" }}

- {{ if .SurnameMatchesDonor }} + {{ if .MatchIdentity }} + {{ trFormat .App "yourConfirmedIdentityDetailsMatchSomeone" + "DonorFullNamePossessive" (possessive .App .Lpa.Donor.FullName) }} + {{ else if .SurnameMatchesDonor }} {{ trFormat .App "theDonorsLastNameMatchesYours" "DonorFullNamePossessive" (possessive .App .Lpa.Donor.FullName) }} {{ else }} diff --git a/web/template/voucher/confirm_your_name.gohtml b/web/template/voucher/confirm_your_name.gohtml index 849d77f50d..6d54baa398 100644 --- a/web/template/voucher/confirm_your_name.gohtml +++ b/web/template/voucher/confirm_your_name.gohtml @@ -3,7 +3,7 @@ {{ define "pageTitle" }}{{ tr .App "confirmYourName" }}{{ end }} {{ define "main" }} - {{ $canChange := not .Tasks.ConfirmYourIdentity.IsCompleted }} + {{ $canChange := .Tasks.ConfirmYourIdentity.IsNotStarted }}