diff --git a/addons/addon-base-ui/packages/base-ui/src/helpers/settings.js b/addons/addon-base-ui/packages/base-ui/src/helpers/settings.js index 0717f6c9f4..6b7219642c 100644 --- a/addons/addon-base-ui/packages/base-ui/src/helpers/settings.js +++ b/addons/addon-base-ui/packages/base-ui/src/helpers/settings.js @@ -30,6 +30,10 @@ const branding = { title: process.env.REACT_APP_USER_REGISTRATION_TITLE, summary: process.env.REACT_APP_USER_REGISTRATION_SUMMARY, success: process.env.REACT_APP_USER_REGISTRATION_SUCCESS, + tosRequired: process.env.REACT_APP_USER_REGISTRATION_TOS_REQUIRED === 'true', + }, + tos: { + onLanding: process.env.REACT_APP_TOS_LINK_ON_LANDING === 'true', }, main: { title: process.env.REACT_APP_BRAND_MAIN_TITLE, diff --git a/addons/addon-custom/packages/main/lib/schemas/register-user.json b/addons/addon-custom/packages/main/lib/schemas/register-user.json index 64da161c45..fea1d1406b 100644 --- a/addons/addon-custom/packages/main/lib/schemas/register-user.json +++ b/addons/addon-custom/packages/main/lib/schemas/register-user.json @@ -27,5 +27,5 @@ "pattern": "\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+([+-][0-2]\\d:[0-5]\\d|Z)" } }, - "required": ["email", "firstName", "lastName", "acceptedTerms"] + "required": ["email", "firstName", "lastName"] } diff --git a/addons/addon-custom/packages/main/src/extend/withAuth.js b/addons/addon-custom/packages/main/src/extend/withAuth.js index bd87259472..07aadb689f 100644 --- a/addons/addon-custom/packages/main/src/extend/withAuth.js +++ b/addons/addon-custom/packages/main/src/extend/withAuth.js @@ -56,8 +56,12 @@ function RegisterLogin(enableCustomRegister) { Register )} - Terms of Service -
+ {branding.tos.onLanding && ( + <> + Terms of Service +
+ + )} {branding.main.loginWarning} ); diff --git a/addons/addon-custom/packages/main/src/parts/Register.js b/addons/addon-custom/packages/main/src/parts/Register.js index 77f73a1248..053fe40f9c 100644 --- a/addons/addon-custom/packages/main/src/parts/Register.js +++ b/addons/addon-custom/packages/main/src/parts/Register.js @@ -83,6 +83,32 @@ class Register extends React.Component { }; } + renderTOS() { + return ( + <> + {this.terms.value !== termsState.unset.value && } + {this.terms.label}   + { + this.termsModalButton = ref; + }} + > + Terms of Service + + } + closeOnDimmerClick + acceptAction={this.setTerms(termsState.accepted)} + declineAction={this.setTerms(termsState.declined)} + /> + + ); + } + renderRegisterationForm() { return (
@@ -101,28 +127,8 @@ class Register extends React.Component { {this.renderField('email')} + {branding.register.tosRequired &&
{this.renderTOS()}
}
- {this.terms.value !== termsState.unset.value && } - {this.terms.label}   - { - this.termsModalButton = ref; - }} - > - Terms of Service - - } - closeOnDimmerClick - acceptAction={this.setTerms(termsState.accepted)} - declineAction={this.setTerms(termsState.declined)} - /> -
-
{this.errors.form && ( @@ -130,11 +136,7 @@ class Register extends React.Component {
)} - + Create a new Service Workbench account @@ -145,6 +147,10 @@ class Register extends React.Component { ); } + submitDisabled() { + return branding.register.tosRequired ? this.terms.value !== termsState.accepted.value : false; + } + renderConfirmation() { return (
@@ -207,20 +213,24 @@ class Register extends React.Component { return; } - // Validate that the terms have been accepted - if (this.terms.value !== termsState.accepted.value) { + // Validate that the terms have been accepted, if required + let acceptedTerms; + if (branding.register.tosRequired && this.terms.value !== termsState.accepted.value) { runInAction(() => { this.errors.form = termsErrorText; this.formProcessing = false; }); return; } + if (branding.register.tosRequired) { + acceptedTerms = new Date().toISOString(); + } const result = await registerUser({ firstName: this.user.firstName, lastName: this.user.lastName, email: this.user.email, - acceptedTerms: new Date().toISOString(), + acceptedTerms, }); // if we encounter an error then don't continue to process the form and instead display a message if (result.error) { diff --git a/main/config/settings/example.yml b/main/config/settings/example.yml index 022684a95e..e4d85b2cfa 100644 --- a/main/config/settings/example.yml +++ b/main/config/settings/example.yml @@ -157,5 +157,11 @@ HostedZoneId: 'Z02455261RJ9QQPVHFZGA' #userRegistrationSuccess: "

Your Service Workbench account has been successfully created. What you should expect next:

  1. The Service Workbench administrator will review your account.
  2. Once your account is activated, you can login to Service Workbench and start your research.
" #loginWarning: "WARNING: You are entering a secure environment." +# Require the TOS to be accepted before registration can occur. +#tosRequired: true + +# Should the TOS link be enabled on the landing page. +#tosLinkOnLanding: true + # URL for help link #helpUrl: about:blank \ No newline at end of file diff --git a/main/solution/post-deployment/config/infra/functions.yml b/main/solution/post-deployment/config/infra/functions.yml index 6b871858e4..4bb1012f2f 100644 --- a/main/solution/post-deployment/config/infra/functions.yml +++ b/main/solution/post-deployment/config/infra/functions.yml @@ -42,6 +42,8 @@ postDeployment: APP_STUDY_DATA_BUCKET_NAME: ${self:custom.settings.studyDataBucketName} APP_ENABLE_NATIVE_USER_POOL_USERS: ${self:custom.settings.enableNativeUserPoolUsers} APP_ENABLE_CUSTOM_REGISTRATION: ${self:custom.settings.enableCustomRegistration} + APP_TOS_LINK_ON_LANDING : ${self:custom.settings.tosLinkOnLanding} + APP_USER_REGISTRATION_TOS_REQUIRED: ${self:custom.settings.tosRequired} APP_AUTO_CONFIRM_NATIVE_USERS: ${self:custom.settings.autoConfirmNativeUsers} APP_NATIVE_ADMIN_PASSWORD_PARAM_NAME: ${self:custom.settings.nativeAdminPasswordParamName} APP_ENV_NAME: ${self:custom.settings.envName} diff --git a/main/solution/post-deployment/config/settings/.defaults.yml b/main/solution/post-deployment/config/settings/.defaults.yml index eed64ce4dd..9f6cc110ff 100644 --- a/main/solution/post-deployment/config/settings/.defaults.yml +++ b/main/solution/post-deployment/config/settings/.defaults.yml @@ -36,6 +36,12 @@ enableUserSignUps: true # Please also include the registration parameters to customize the registration page. enableCustomRegistration: false +# Require the TOS to be accepted before registration can occur. +tosRequired: true + +# Should the TOS link be enabled on the landing page. +tosLinkOnLanding: true + # Cognito domain prefix. Note random string will be padded at the end if specified domain is not available cognitoUserPoolDomainPrefix: ${self:custom.settings.envName}-${self:custom.settings.solutionName} diff --git a/main/solution/ui/config/environment/env-template.yml b/main/solution/ui/config/environment/env-template.yml index 08e1f7cfd0..a4dd23453b 100644 --- a/main/solution/ui/config/environment/env-template.yml +++ b/main/solution/ui/config/environment/env-template.yml @@ -26,6 +26,8 @@ REACT_APP_USER_REGISTRATION_SUMMARY: ${self:custom.settings.userRegistrationSumm REACT_APP_USER_REGISTRATION_SUCCESS: ${self:custom.settings.userRegistrationSuccess} REACT_APP_LOGIN_WARNING: ${self:custom.settings.loginWarning} REACT_APP_HELP_URL: ${self:custom.settings.helpUrl} +REACT_APP_USER_REGISTRATION_TOS_REQUIRED: ${self:custom.settings.tosRequired} +REACT_APP_TOS_LINK_ON_LANDING: ${self:custom.settings.tosLinkOnLanding} # ======================================================================== # Overrides for .env.local diff --git a/main/solution/ui/config/settings/.defaults.yml b/main/solution/ui/config/settings/.defaults.yml index f8ca55d08c..6aad9fa6f1 100644 --- a/main/solution/ui/config/settings/.defaults.yml +++ b/main/solution/ui/config/settings/.defaults.yml @@ -34,3 +34,9 @@ userRegistrationTitle: "WELCOME TO SERVICE WORKBENCH" userRegistrationSummary: "

Service Workbench provides a self-service, three-click, on-demand service for researchers to build research environments in minutes without needing cloud infrastructure knowledge. Fill out the form below to create your account on Service Workbench hosted on AWS.

" userRegistrationSuccess: "

Your Service Workbench account has been successfully created. What you should expect next:

  1. The Service Workbench administrator will review your account.
  2. Once your account is activated, you can login to Service Workbench and start your research.
" loginWarning: "" + +# Require the TOS to be accepted before registration can occur. +tosRequired: true + +# Should the TOS link be enabled on the landing page. +tosLinkOnLanding: true