From faf3fc4b6ff3ca6f269b7c5475145cd552df5a73 Mon Sep 17 00:00:00 2001 From: Josh Worden Date: Thu, 3 Nov 2022 13:47:53 -0500 Subject: [PATCH] Add change email config and placeholder template --- .../browser/authenticate.vue | 5 +++++ .../marko-web-identity-x/browser/profile.vue | 12 ++++++++++++ .../components/form-authenticate.marko | 5 +++-- .../components/form-profile.marko | 1 + packages/marko-web-identity-x/config.js | 10 +++++++++- services/example-website/config/identity-x.js | 1 + .../server/templates/user/change-email.marko | 16 ++++++++++++++++ .../server/templates/user/index.js | 2 ++ 8 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 services/example-website/server/templates/user/change-email.marko diff --git a/packages/marko-web-identity-x/browser/authenticate.vue b/packages/marko-web-identity-x/browser/authenticate.vue index 3808f8e5c..79eea8e04 100644 --- a/packages/marko-web-identity-x/browser/authenticate.vue +++ b/packages/marko-web-identity-x/browser/authenticate.vue @@ -23,6 +23,7 @@ :button-label="buttonLabel" :call-to-action="callToAction" :default-field-labels="defaultFieldLabels" + :enable-change-email="enableChangeEmail" @profile-updated="redirect" /> @@ -128,6 +129,10 @@ export default { type: String, default: null, }, + enableChangeEmail: { + type: Boolean, + default: false, + }, }, /** diff --git a/packages/marko-web-identity-x/browser/profile.vue b/packages/marko-web-identity-x/browser/profile.vue index 30e9f1298..01ba00af1 100644 --- a/packages/marko-web-identity-x/browser/profile.vue +++ b/packages/marko-web-identity-x/browser/profile.vue @@ -158,6 +158,14 @@ + + Change email + {{ submitMessage }} @@ -313,6 +321,10 @@ export default { type: String, default: null, }, + enableChangeEmail: { + type: Boolean, + default: false, + }, }, /** diff --git a/packages/marko-web-identity-x/components/form-authenticate.marko b/packages/marko-web-identity-x/components/form-authenticate.marko index 7bf0d4d27..91fa15601 100644 --- a/packages/marko-web-identity-x/components/form-authenticate.marko +++ b/packages/marko-web-identity-x/components/form-authenticate.marko @@ -14,9 +14,9 @@ $ const additionalEventData = defaultValue(input.additionalEventData, {}); redirectTo: query.redirectTo, requiredServerFields: identityX.config.getRequiredServerFields(), requiredClientFields: identityX.config.getRequiredClientFields(), - defaultCountryCode: identityX.config.get('defaultCountryCode'), + defaultCountryCode: identityX.config.get("defaultCountryCode"), defaultFieldLabels: identityX.config.get("defaultFieldLabels"), - booleanQuestionsLabel: identityX.config.get('booleanQuestionsLabel'), + booleanQuestionsLabel: identityX.config.get("booleanQuestionsLabel"), hiddenFields: identityX.config.getHiddenFields(), endpoints: identityX.config.getEndpoints(), callToAction: input.callToAction, @@ -24,6 +24,7 @@ $ const additionalEventData = defaultValue(input.additionalEventData, {}); consentPolicy: get(application, "organization.consentPolicy"), emailConsentRequest: get(application, "organization.emailConsentRequest"), regionalConsentPolicies: get(application, "organization.regionalConsentPolicies"), + enableChangeEmail: identityX.config.get("enableChangeEmail") }; diff --git a/packages/marko-web-identity-x/components/form-profile.marko b/packages/marko-web-identity-x/components/form-profile.marko index e913dc3aa..3090052f2 100644 --- a/packages/marko-web-identity-x/components/form-profile.marko +++ b/packages/marko-web-identity-x/components/form-profile.marko @@ -25,6 +25,7 @@ $ const additionalEventData = defaultValue(input.additionalEventData, {}); appContextId: identityX.config.get("appContextId"), regionalConsentPolicies: get(application, "organization.regionalConsentPolicies"), returnTo: query.returnTo, + enableChangeEmail: identityX.config.get("enableChangeEmail"), }; diff --git a/packages/marko-web-identity-x/config.js b/packages/marko-web-identity-x/config.js index 832b650aa..debd20fec 100644 --- a/packages/marko-web-identity-x/config.js +++ b/packages/marko-web-identity-x/config.js @@ -32,6 +32,7 @@ class IdentityXConfiguration { this.appId = appId; this.apiToken = apiToken; this.options = { + enableChangeEmail: false, requiredServerFields, requiredClientFields, defaultFieldLabels, @@ -48,7 +49,14 @@ class IdentityXConfiguration { ...rest, }; - this.endpointTypes = ['authenticate', 'login', 'logout', 'register', 'profile']; + this.endpointTypes = [ + 'authenticate', + 'changeEmail', + 'login', + 'logout', + 'register', + 'profile', + ]; this.hooks = validHooks.reduce((o, name) => ({ ...o, [name]: [] }), {}); } diff --git a/services/example-website/config/identity-x.js b/services/example-website/config/identity-x.js index 601131f38..74c5be992 100644 --- a/services/example-website/config/identity-x.js +++ b/services/example-website/config/identity-x.js @@ -8,6 +8,7 @@ module.exports = new IdentityXConfiguration({ requiredServerFields: ['givenName', 'familyName', 'countryCode'], requiredClientFields: ['regionCode', 'countryCode'], booleanQuestionsLabel: 'Choose your subscriptions:', + enableChangeEmail: true, defaultFieldLabels: { phoneNumber: 'Mobile Phone', organization: 'Company Name', diff --git a/services/example-website/server/templates/user/change-email.marko b/services/example-website/server/templates/user/change-email.marko new file mode 100644 index 000000000..4b10375a0 --- /dev/null +++ b/services/example-website/server/templates/user/change-email.marko @@ -0,0 +1,16 @@ +$ const { config } = out.global; + +$ const type = "change-email"; +$ const title = "Change Email"; + + + <@page> + + <@section> +

Change your email address

+

This feature is coming soon!

+

If you need assistance, please reach out to our support team.

+ +
+ +
diff --git a/services/example-website/server/templates/user/index.js b/services/example-website/server/templates/user/index.js index 0e875b935..3503f1694 100644 --- a/services/example-website/server/templates/user/index.js +++ b/services/example-website/server/templates/user/index.js @@ -1,10 +1,12 @@ const authenticate = require('./authenticate'); +const changeEmail = require('./change-email'); const login = require('./login'); const logout = require('./logout'); const profile = require('./profile'); module.exports = { authenticate, + changeEmail, login, logout, profile,