Skip to content

Commit

Permalink
Merge pull request #1418 from govuk-one-login/AUT-1339/new-identity-p…
Browse files Browse the repository at this point in the history
…roving-forms

AUT 1339: New "A problem proving your identity" section of contact forms
  • Loading branch information
gtvj authored Mar 5, 2024
2 parents 3d24ac0 + 0d0466a commit 9db2f04
Show file tree
Hide file tree
Showing 17 changed files with 759 additions and 170 deletions.
7 changes: 7 additions & 0 deletions src/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export const CONTACT_US_THEMES = {
PROVING_IDENTITY_FACE_TO_FACE_TECHNICAL_PROBLEM:
"face_to_face_technical_problem",
PROVING_IDENTITY_FACE_TO_FACE_ANOTHER_PROBLEM: "face_to_face_something_else",
PROVING_IDENTITY_PROBLEM_ANSWERING_SECURITY_QUESTIONS:
"proving_identity_problem_answering_security_questions",
PROVING_IDENTITY_PROBLEM_WITH_IDENTITY_DOCUMENT:
"proving_identity_problem_with_identity_document",
PROVING_IDENTITY_NEED_TO_UPDATE_PERSONAL_INFORMATION:
"proving_identity_need_to_update_personal_information",
PROVING_IDENTITY_SOMETHING_ELSE: "proving_identity_something_else",
};

export const CONTACT_US_FIELD_MAX_LENGTH = 1200;
Expand Down
95 changes: 83 additions & 12 deletions src/components/contact-us/contact-us-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ const themeToPageTitle = {
"pages.contactUsQuestions.provingIdentityFaceToFaceTechnicalProblem.title",
[CONTACT_US_THEMES.PROVING_IDENTITY_FACE_TO_FACE_ANOTHER_PROBLEM]:
"pages.contactUsQuestions.provingIdentityFaceToFaceSomethingElse.title",
[CONTACT_US_THEMES.PROVING_IDENTITY_PROBLEM_ANSWERING_SECURITY_QUESTIONS]:
"pages.contactUsQuestions.provingIdentityProblemAnsweringSecurityQuestions.title",
[CONTACT_US_THEMES.PROVING_IDENTITY_PROBLEM_WITH_IDENTITY_DOCUMENT]:
"pages.contactUsQuestions.provingIdentityProblemWithIdentityDocument.title",
[CONTACT_US_THEMES.PROVING_IDENTITY_NEED_TO_UPDATE_PERSONAL_INFORMATION]:
"pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.title",
[CONTACT_US_THEMES.PROVING_IDENTITY_SOMETHING_ELSE]:
"pages.contactUsQuestions.provingIdentitySomethingElse.title",
};

const somethingElseSubThemeToPageTitle = {
Expand Down Expand Up @@ -285,8 +293,25 @@ export function getPreferredLanguage(languageCode: string): string {
return "Language code not set";
}

export function getNextUrlBasedOnTheme(theme: string): string {
let url: string = PATH_NAMES.CONTACT_US_QUESTIONS;

if (
[
CONTACT_US_THEMES.ACCOUNT_CREATION,
CONTACT_US_THEMES.SIGNING_IN,
CONTACT_US_THEMES.ID_CHECK_APP,
CONTACT_US_THEMES.PROVING_IDENTITY_FACE_TO_FACE,
CONTACT_US_THEMES.PROVING_IDENTITY,
].includes(theme)
) {
url = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION;
}

return url;
}

export function contactUsFormPost(req: Request, res: Response): void {
let url = PATH_NAMES.CONTACT_US_QUESTIONS;
const queryParams = new URLSearchParams({
theme: req.body.theme,
referer: validateReferer(req.body.referer, serviceDomain),
Expand All @@ -302,17 +327,9 @@ export function contactUsFormPost(req: Request, res: Response): void {
);
}

if (
[
CONTACT_US_THEMES.ACCOUNT_CREATION,
CONTACT_US_THEMES.SIGNING_IN,
CONTACT_US_THEMES.ID_CHECK_APP,
CONTACT_US_THEMES.PROVING_IDENTITY_FACE_TO_FACE,
].includes(req.body.theme)
) {
url = PATH_NAMES.CONTACT_US_FURTHER_INFORMATION;
}
res.redirect(url + "?" + queryParams.toString());
res.redirect(
getNextUrlBasedOnTheme(req.body.theme) + "?" + queryParams.toString()
);
}

export function furtherInformationGet(req: Request, res: Response): void {
Expand Down Expand Up @@ -776,6 +793,38 @@ export function getQuestionsFromFormTypeForMessageBody(
{ lng: "en" }
),
},
provingIdentityProblemAnsweringSecurityQuestions: {
issueDescription: req.t(
"pages.contactUsQuestions.provingIdentityProblemAnsweringSecurityQuestions.section1.label",
{ lng: "en" }
),
},
provingIdentityProblemWithIdentityDocument: {
issueDescription: req.t(
"pages.contactUsQuestions.provingIdentityProblemWithIdentityDocument.section2.label",
{ lng: "en" }
),
},
provingIdentityNeedToUpdatePersonalInformation: {
issueDescription: req.t(
"pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.section1.label",
{ lng: "en" }
),
additionalDescription: req.t(
"pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.section2.label",
{ lng: "en" }
),
},
provingIdentitySomethingElse: {
issueDescription: req.t(
"pages.contactUsQuestions.provingIdentitySomethingElse.section1.label",
{ lng: "en" }
),
additionalDescription: req.t(
"pages.contactUsQuestions.provingIdentitySomethingElse.section2.label",
{ lng: "en" }
),
},
};

return formTypeToQuestions[formType];
Expand Down Expand Up @@ -928,6 +977,25 @@ export function getQuestionFromThemes(
),
};

const provingIdentitySubthemeToQuestion: { [key: string]: any } = {
proving_identity_problem_answering_security_questions: req.t(
"pages.contactUsQuestions.provingIdentityProblemAnsweringSecurityQuestions.title",
{ lng: "en" }
),
proving_identity_problem_with_identity_document: req.t(
"pages.contactUsQuestions.provingIdentityProblemWithIdentityDocument.title",
{ lng: "en" }
),
proving_identity_need_to_update_personal_information: req.t(
"pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.title",
{ lng: "en" }
),
proving_identity_something_else: req.t(
"pages.contactUsQuestions.provingIdentitySomethingElse.title",
{ lng: "en" }
),
};

const themeQuestion = themesToQuestions[theme];
let subthemeQuestion;
if (subtheme) {
Expand All @@ -943,6 +1011,9 @@ export function getQuestionFromThemes(
if (theme == CONTACT_US_THEMES.PROVING_IDENTITY_FACE_TO_FACE) {
subthemeQuestion = provingIdentityFaceToFaceSubthemeToQuestion[subtheme];
}
if (theme == CONTACT_US_THEMES.PROVING_IDENTITY) {
subthemeQuestion = provingIdentitySubthemeToQuestion[subtheme];
}
}
return {
themeQuestion,
Expand Down
14 changes: 14 additions & 0 deletions src/components/contact-us/contact-us-questions-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ export function validateContactUsQuestionsRequest(): ValidationChainFunc {
{ value, lng: req.i18n.lng }
);
}),
body("identityDocumentUsed")
.if(body("theme").equals("proving_identity"))
.if(
body("subtheme").equals(
"proving_identity_problem_with_identity_document"
)
)
.notEmpty()
.withMessage((value, { req }) => {
return req.t(
"pages.contactUsQuestions.provingIdentityProblemWithIdentityDocument.identityDocument.errorMessage",
{ value, lng: req.i18n.lng }
);
}),
body("issueDescription")
.optional()
.notEmpty()
Expand Down
38 changes: 22 additions & 16 deletions src/components/contact-us/contact-us-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ import { body } from "express-validator";
import { validateBodyMiddleware } from "../../middleware/form-validation-middleware";
import { ValidationChainFunc } from "../../types";

export function getContactUsErrorMessage(theme: string): string {
let errorMessage: string = "pages.contactUsPublic.section3.errorMessage";
if (theme === "signing_in") {
errorMessage =
"pages.contactUsFurtherInformation.signingIn.section1.errorMessage";
} else if (theme === "account_creation") {
errorMessage =
"pages.contactUsFurtherInformation.accountCreation.section1.errorMessage";
} else if (theme === "id_check_app") {
errorMessage =
"pages.contactUsFurtherInformation.idCheckApp.section1.errorMessage";
} else if (theme === "id_face_to_face") {
errorMessage =
"pages.contactUsFurtherInformation.provingIdentityFaceToFace.section1.errorMessage";
} else if (theme === "proving_identity") {
errorMessage =
"pages.contactUsFurtherInformation.provingIdentity.section1.errorMessage";
}
return errorMessage;
}

export function validateContactUsRequest(
template: string,
bodyType: string
Expand All @@ -10,22 +31,7 @@ export function validateContactUsRequest(
body(bodyType)
.notEmpty()
.withMessage((value, { req }) => {
let errorMessage = "pages.contactUsPublic.section3.errorMessage";
if (req.body.theme === "signing_in") {
errorMessage =
"pages.contactUsFurtherInformation.signingIn.section1.errorMessage";
} else if (req.body.theme === "account_creation") {
errorMessage =
"pages.contactUsFurtherInformation.accountCreation.section1.errorMessage";
} else if (req.body.theme === "id_check_app") {
errorMessage =
"pages.contactUsFurtherInformation.idCheckApp.section1.errorMessage";
} else if (req.body.theme === "id_face_to_face") {
errorMessage =
"pages.contactUsFurtherInformation.provingIdentityFaceToFace.section1.errorMessage";
}

return req.t(errorMessage, {
return req.t(getContactUsErrorMessage(req.body.theme), {
value,
});
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<h1 class="govuk-heading-l govuk-!-margin-top-0 govuk-!-margin-bottom-3">
{{ 'pages.contactUsFurtherInformation.provingIdentity.header' | translate }}
</h1>

<form action="/contact-us-further-information" method="post" novalidate>

<input type="hidden" name="_csrf" value="{{csrfToken}}"/>
<input type="hidden" name="theme" value="{{theme}}"/>
<input type="hidden" name="referer" value="{{referer}}"/>
<input type="hidden" name="fromURL" value="{{fromURL}}"/>

{% include 'contact-us/questions/_id-check-app-hidden-fields.njk' %}

{{ govukRadios({
name: "subtheme",
fieldset: {
legend: {
text: 'pages.contactUsFurtherInformation.provingIdentity.section1.header' | translate,
isPageHeading: false,
classes: "govuk-fieldset__legend--m"
}
},
items: [
{
value: "proving_identity_problem_answering_security_questions",
text: 'pages.contactUsFurtherInformation.provingIdentity.section1.radio1' | translate
},
{
value: "proving_identity_problem_with_identity_document",
text: 'pages.contactUsFurtherInformation.provingIdentity.section1.radio2' | translate
},
{
value: "proving_identity_need_to_update_personal_information",
text: 'pages.contactUsFurtherInformation.provingIdentity.section1.radio3' | translate
},
{
value: "proving_identity_technical_problem",
text: 'pages.contactUsFurtherInformation.provingIdentity.section1.radio4' | translate
},
{
value: "proving_identity_something_else",
text: 'pages.contactUsFurtherInformation.provingIdentity.section1.radio5' | translate
}
],
errorMessage: {
text: errors['subtheme'].text
} if (errors['subtheme'])
}) }}


{{ govukButton({
"text": "general.continue.label" | translate,
"type": "Submit",
"preventDoubleClick": true
}) }}

</form>
8 changes: 8 additions & 0 deletions src/components/contact-us/further-information/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
{% set pageTitleName = 'pages.contactUsFurtherInformation.provingIdentityFaceToFace.title' | translate %}
{% endif %}

{% if theme == 'proving_identity' %}
{% set pageTitleName = 'pages.contactUsFurtherInformation.provingIdentity.title' | translate %}
{% endif %}

{% block content %}
{% include "common/errors/errorSummary.njk" %}

Expand All @@ -42,4 +46,8 @@
{% include 'contact-us/further-information/_proving-identity-post-office-further-information.njk' %}
{% endif %}

{% if theme == 'proving_identity' %}
{% include 'contact-us/further-information/_proving-identity-further-information.njk' %}
{% endif %}

{% endblock %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<h1 class="govuk-heading-l govuk-!-margin-top-0 govuk-!-margin-bottom-3">
{{ 'pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.header' | translate }}
</h1>

<form action="{{formSubmissionUrl}}" method="post" novalidate>

<input type="hidden" name="_csrf" value="{{csrfToken}}"/>
<input type="hidden" name="theme" value="{{theme}}"/>
<input type="hidden" name="subtheme" value="{{subtheme}}"/>
<input type="hidden" name="backurl" value="{{backurl}}"/>
<input type="hidden" name="fromURL" value="{{fromURL}}"/>
<input type="hidden" name="formType" value="provingIdentityNeedToUpdatePersonalInformation"/>
<input type="hidden" name="referer" value="{{referer}}"/>
{% include 'contact-us/questions/_id-check-app-hidden-fields.njk' %}

{{ govukCharacterCount({
label: {
text: 'pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.section1.label' | translate,
classes: "govuk-label--s"
},
id: "issueDescription",
name: "issueDescription",
maxlength: contactUsFieldMaxLength,
value: issueDescription,
charactersAtLimitText: 'pages.contactUsQuestions.characterCountComponent.charactersAtLimitText' | translate,
charactersUnderLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.other' | translate,
one: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.one' | translate
},
charactersOverLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.other' | translate,
one: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.one' | translate
},
errorMessage: {
text: errors['issueDescription'].text | translate | replace('[maximumCharacters]', contactUsFieldMaxLength.toLocaleString())
} if (errors['issueDescription'])
}) }}

{{ govukCharacterCount({
label: {
text: 'pages.contactUsQuestions.provingIdentityNeedToUpdatePersonalInformation.section2.label' | translate,
classes: "govuk-label--s"
},

id: "additionalDescription",
name: "additionalDescription",
maxlength: contactUsFieldMaxLength,
value: additionalDescription,
charactersAtLimitText: 'pages.contactUsQuestions.characterCountComponent.charactersAtLimitText' | translate,
charactersUnderLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.other' | translate,
one: 'pages.contactUsQuestions.characterCountComponent.charactersUnderLimitText.one' | translate
},
charactersOverLimitText: {
other: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.other' | translate,
one: 'pages.contactUsQuestions.characterCountComponent.charactersOverLimitText.one' | translate
},
errorMessage: {
text: errors['additionalDescription'].text | translate | replace('[maximumCharacters]', contactUsFieldMaxLength.toLocaleString())
} if (errors['additionalDescription'])
}) }}

{% include 'contact-us/questions/_service-trying-to-use.njk' %}

{{ govukWarningText({
text:'pages.contactUsQuestions.personalInformation.paragraph1' | translate,
iconFallbackText: "Warning"
}) }}

{% include 'contact-us/questions/_reply_by_email.njk' %}

{{ govukButton({
"text": "general.sendMessage" | translate,
"type": "Submit",
"preventDoubleClick": true
}) }}

</form>
Loading

0 comments on commit 9db2f04

Please sign in to comment.