diff --git a/CHANGELOG.md b/CHANGELOG.md index 8703614221..8a8e8e15b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ The types of changes are: - Set `privacyDeclarationDeprecatedFields` flags to false and set `userCannotModify` to true [2987](https://github.com/ethyca/fides/pull/2987) - Restored `nav-config` back to the admin-ui [#2990](https://github.com/ethyca/fides/pull/2990) +- Modify privacy center default config to only request email identities, and add validation preventing requesting both email & phone identities [#2539](https://github.com/ethyca/fides/pull/2539) + ### Removed diff --git a/clients/cypress-e2e/cypress/e2e/smoke_test.cy.ts b/clients/cypress-e2e/cypress/e2e/smoke_test.cy.ts index 740bc95472..de0071cc79 100644 --- a/clients/cypress-e2e/cypress/e2e/smoke_test.cy.ts +++ b/clients/cypress-e2e/cypress/e2e/smoke_test.cy.ts @@ -16,10 +16,7 @@ describe("Smoke test", () => { cy.visit(PRIVACY_CENTER_URL); cy.getByTestId("card").contains("Access your data").click(); cy.getByTestId("privacy-request-form").within(() => { - cy.get("input#name").type("Jenny"); cy.get("input#email").type("jenny@example.com"); - - cy.get("input#phone").type("555 867 5309"); cy.get("button").contains("Continue").click(); }); diff --git a/clients/privacy-center/components/modals/consent-request-modal/ConsentRequestForm.tsx b/clients/privacy-center/components/modals/consent-request-modal/ConsentRequestForm.tsx index 861afab8ee..d587e260e1 100644 --- a/clients/privacy-center/components/modals/consent-request-modal/ConsentRequestForm.tsx +++ b/clients/privacy-center/components/modals/consent-request-modal/ConsentRequestForm.tsx @@ -108,8 +108,32 @@ const useConsentRequestForm = ({ } }, validationSchema: Yup.object().shape({ - email: emailValidation(identityInputs?.email), - phone: phoneValidation(identityInputs?.phone), + email: emailValidation(identityInputs?.email).test( + "one of email or phone entered", + "You must enter either email or phone", + (value, context) => { + if ( + identityInputs?.email === "optional" && + identityInputs?.phone === "optional" + ) { + return Boolean(context.parent.phone || context.parent.email); + } + return true; + } + ), + phone: phoneValidation(identityInputs?.phone).test( + "one of email or phone entered", + "You must enter either email or phone", + (value, context) => { + if ( + identityInputs?.email === "optional" && + identityInputs?.phone === "optional" + ) { + return Boolean(context.parent.phone || context.parent.email); + } + return true; + } + ), }), }); @@ -186,6 +210,9 @@ const ConsentRequestForm: React.FC = ({ onBlur={handleBlur} value={values.email} isInvalid={touched.email && Boolean(errors.email)} + isDisabled={Boolean( + typeof values.phone !== "undefined" && values.phone + )} /> {errors.email} @@ -195,6 +222,9 @@ const ConsentRequestForm: React.FC = ({ id="phone" isInvalid={touched.phone && Boolean(errors.phone)} isRequired={identityInputs.phone === "required"} + isDisabled={Boolean( + typeof values.email !== "undefined" && values.email + )} > Phone { + if ( + identityInputs?.email === "optional" && + identityInputs?.phone === "optional" + ) { + return Boolean(context.parent.phone || context.parent.email); + } + return true; + } + ), + phone: phoneValidation(identityInputs?.phone).test( + "one of email or phone entered", + "You must enter either email or phone", + (value, context) => { + if ( + identityInputs?.email === "optional" && + identityInputs?.phone === "optional" + ) { + return Boolean(context.parent.phone || context.parent.email); + } + return true; + } + ), }), }); @@ -237,6 +261,9 @@ const PrivacyRequestForm: React.FC = ({ onChange={handleChange} onBlur={handleBlur} value={values.email} + isDisabled={Boolean( + typeof values.phone !== "undefined" && values.phone + )} /> {errors.email} @@ -256,6 +283,9 @@ const PrivacyRequestForm: React.FC = ({ }} onBlur={handleBlur} value={values.phone} + isDisabled={Boolean( + typeof values.email !== "undefined" && values.email + )} /> {errors.phone} diff --git a/clients/privacy-center/config/config.json b/clients/privacy-center/config/config.json index 12b09b1d97..3e7b75b2b9 100644 --- a/clients/privacy-center/config/config.json +++ b/clients/privacy-center/config/config.json @@ -13,9 +13,7 @@ "title": "Access your data", "description": "We will provide you a report of all your personal data.", "identity_inputs": { - "name": "optional", - "email": "required", - "phone": "optional" + "email": "required" } }, { @@ -24,9 +22,7 @@ "title": "Erase your data", "description": "We will erase all of your personal data. This action cannot be undone.", "identity_inputs": { - "name": "optional", - "email": "required", - "phone": "optional" + "email": "required" } } ], @@ -36,8 +32,7 @@ "description": "Manage your consent preferences, including the option to select 'Do Not Sell My Personal Information'.", "icon_path": "/consent.svg", "identity_inputs": { - "email": "required", - "phone": "optional" + "email": "required" }, "title": "Manage your consent" }, diff --git a/clients/privacy-center/config/examples/basic.json b/clients/privacy-center/config/examples/basic.json index f63d8af595..b9ed78f899 100644 --- a/clients/privacy-center/config/examples/basic.json +++ b/clients/privacy-center/config/examples/basic.json @@ -11,9 +11,7 @@ "title": "Download your data", "description": "We will email you a report of the data related to your account.", "identity_inputs": { - "name": "required", - "email": "required", - "phone": "optional" + "email": "required" } }, { @@ -22,7 +20,6 @@ "title": "Delete your data", "description": "We will delete all of your account data. This action cannot be undone.", "identity_inputs": { - "name": "optional", "email": "required" } }, @@ -32,7 +29,7 @@ "title": "Edit your data", "description": "Manage how we use your data, including Do Not Sell My Personal Information.", "identity_inputs": { - "phone": "optional" + "email": "required" } } ] diff --git a/clients/privacy-center/cypress/e2e/privacy-request.cy.ts b/clients/privacy-center/cypress/e2e/privacy-request.cy.ts index dcfab3e2a0..2c629dbd1d 100644 --- a/clients/privacy-center/cypress/e2e/privacy-request.cy.ts +++ b/clients/privacy-center/cypress/e2e/privacy-request.cy.ts @@ -13,37 +13,6 @@ describe("Privacy request", () => { ).as("postPrivacyRequestVerify"); }); - it("can verify phone and navigate to form", () => { - cy.visit("/"); - cy.getByTestId("card").contains("Access your data").click(); - - cy.getByTestId("privacy-request-form").within(() => { - cy.get("input#name").type("Jenny"); - cy.get("input#email").type("jenny@example.com"); - - cy.get("input#phone").type("555 867 5309"); - cy.get("select[name=phoneCountry]").should("have.value", "US"); - cy.get("input#phone").clear().type("+44 55 8675 3090"); - cy.get("select[name=phoneCountry]").should("have.value", "GB"); - - cy.get("button").contains("Continue").click(); - }); - cy.wait("@postPrivacyRequest").then((interception) => { - expect(interception.request.body[0].identity).to.eql({ - email: "jenny@example.com", - phone_number: "+445586753090", - }); - }); - - cy.getByTestId("verification-form").within(() => { - cy.get("input").type("112358"); - cy.get("button").contains("Submit code").click(); - }); - cy.wait("@postPrivacyRequestVerify"); - - cy.getByTestId("request-submitted"); - }); - it("requires valid inputs", () => { cy.visit("/"); cy.getByTestId("card").contains("Access your data").click(); @@ -51,20 +20,17 @@ describe("Privacy request", () => { cy.getByTestId("privacy-request-form").within(() => { // This block uses `.root()` to keep queries within the form. This is necessary because of // `.blur()` which triggers input validation. - cy.root().get("input#email").type("invalid email"); - cy.root().get("input#phone").type("123 456 7890 1234567").blur(); + // test email being typed, continue becoming disabled due to invalid email + cy.root().get("input#email").type("invalid email").blur(); cy.root().should("contain", "Email is invalid"); - cy.root().should("contain", "Phone is invalid"); cy.root().get("button").contains("Continue").should("be.disabled"); + cy.root().get("input#email").clear().blur(); - cy.root().get("input#email").type("valid@example.com"); - cy.root().get("input#phone").clear().type("123 456 7890").blur(); - cy.root().get("button").contains("Continue").should("be.enabled"); - - // The phone input is optional (in the default config) so it can be left blank. - cy.root().get("input#phone").clear().blur(); + // test valid email, continue becoming enabled due to valid email + cy.root().get("input#email").type("valid@example.com").blur(); cy.root().get("button").contains("Continue").should("be.enabled"); + cy.root().get("input#email").clear().blur(); }); }); }); diff --git a/src/fides/data/sample_project/privacy_center/config/config.json b/src/fides/data/sample_project/privacy_center/config/config.json index 18b6b94b16..cbe3d75991 100644 --- a/src/fides/data/sample_project/privacy_center/config/config.json +++ b/src/fides/data/sample_project/privacy_center/config/config.json @@ -11,9 +11,7 @@ "title": "Access your data", "description": "We will provide you a report of all your personal data.", "identity_inputs": { - "name": "optional", - "email": "required", - "phone": "optional" + "email": "required" } }, { @@ -22,9 +20,7 @@ "title": "Erase your data", "description": "We will erase all of your personal data. This action cannot be undone.", "identity_inputs": { - "name": "optional", - "email": "required", - "phone": "optional" + "email": "required" } } ], diff --git a/src/fides/data/test_env/privacy_center_config/config.json b/src/fides/data/test_env/privacy_center_config/config.json index ba7c68c786..33be8cdcc4 100644 --- a/src/fides/data/test_env/privacy_center_config/config.json +++ b/src/fides/data/test_env/privacy_center_config/config.json @@ -12,9 +12,7 @@ "title": "Access your data", "description": "We will provide you a report of all your personal data.", "identity_inputs": { - "name": "optional", - "email": "required", - "phone": "optional" + "email": "required" } }, { @@ -23,9 +21,7 @@ "title": "Erase your data", "description": "We will erase all of your personal data. This action cannot be undone.", "identity_inputs": { - "name": "optional", - "email": "required", - "phone": "optional" + "email": "required" } } ], @@ -38,8 +34,7 @@ "When you use our services, you're trusting us with your information. We understand this is a big responsibility and work hard to protect your information and put you in control." ], "identity_inputs": { - "email": "required", - "phone": "optional" + "email": "required" }, "cookieName": "fides_consent", "policy_key": "default_consent_policy", diff --git a/tests/fixtures/privacy_center_config/bad_test_config.json b/tests/fixtures/privacy_center_config/bad_test_config.json deleted file mode 100644 index 2c84fb4239..0000000000 --- a/tests/fixtures/privacy_center_config/bad_test_config.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "title": "Privacy Center", - "description": "When you use our services, you’re trusting us with your information. We understand this is a big responsibility and work hard to protect your information and put you in control.", - "server_url_development": "http://localhost:8080/api/v1", - "server_url_production": "http://localhost:8080/api/v1", - "logo_path": "/logo.svg", - "actions": [], - "includeConsent": true, - "consent": { - "icon_path": "/consent.svg", - "title": "Manage your consent", - "description": "Manage your consent preferences, including the option to select 'Do Not Sell My Personal Information'.", - "identity_inputs": { - "email": "required", - "phone": "optional" - }, - "policy_key": "default_consent_policy", - "consent_options": [ - { - "fidesDataUseKey": "advertising", - "name": "Data Sales or Sharing", - "description": "We may use some of your personal information for behavioral advertising purposes, which may be interpreted as 'Data Sales' or 'Data Sharing' under regulations such as CCPA, CPRA, VCDPA, etc.", - "url": "https://example.com/privacy#data-sales", - "default": true, - "highlight": false, - "cookieKeys": ["data_sales"], - "executable": false - }, - { - "fidesDataUseKey": "advertising.first_party", - "name": "Email Marketing", - "description": "We may use some of your personal information to contact you about our products & services.", - "url": "https://example.com/privacy#email-marketing", - "default": true, - "highlight": false, - "cookieKeys": [], - "executable": true - }, - { - "fidesDataUseKey": "improve", - "name": "Product Analytics", - "description": "We may use some of your personal information to collect analytics about how you use our products & services.", - "url": "https://example.com/privacy#analytics", - "default": true, - "highlight": false, - "cookieKeys": [], - "executable": false - } - ] - } -} diff --git a/tests/fixtures/privacy_center_config/test_config.json b/tests/fixtures/privacy_center_config/test_config.json deleted file mode 100644 index 22b1c131b0..0000000000 --- a/tests/fixtures/privacy_center_config/test_config.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "title": "Privacy Center", - "description": "When you use our services, you’re trusting us with your information. We understand this is a big responsibility and work hard to protect your information and put you in control.", - "server_url_development": "http://localhost:8080/api/v1", - "server_url_production": "http://localhost:8080/api/v1", - "logo_path": "/logo.svg", - "actions": [], - "includeConsent": true, - "consent": { - "icon_path": "/consent.svg", - "title": "Manage your consent", - "description": "Manage your consent preferences, including the option to select 'Do Not Sell My Personal Information'.", - "identity_inputs": { - "email": "required", - "phone": "optional" - }, - "policy_key": "default_consent_policy", - "consentOptions": [ - { - "fidesDataUseKey": "advertising", - "name": "Data Sales or Sharing", - "description": "We may use some of your personal information for behavioral advertising purposes, which may be interpreted as 'Data Sales' or 'Data Sharing' under regulations such as CCPA, CPRA, VCDPA, etc.", - "url": "https://example.com/privacy#data-sales", - "default": true, - "highlight": false, - "cookieKeys": ["data_sales"], - "executable": false - }, - { - "fidesDataUseKey": "advertising.first_party", - "name": "Email Marketing", - "description": "We may use some of your personal information to contact you about our products & services.", - "url": "https://example.com/privacy#email-marketing", - "default": true, - "highlight": false, - "cookieKeys": [], - "executable": true - }, - { - "fidesDataUseKey": "improve", - "name": "Product Analytics", - "description": "We may use some of your personal information to collect analytics about how you use our products & services.", - "url": "https://example.com/privacy#analytics", - "default": true, - "highlight": false, - "cookieKeys": [], - "executable": false - } - ] - } -}