diff --git a/core/src/main/java/google/registry/model/registrar/Registrar.java b/core/src/main/java/google/registry/model/registrar/Registrar.java index 40662793e..379880df0 100644 --- a/core/src/main/java/google/registry/model/registrar/Registrar.java +++ b/core/src/main/java/google/registry/model/registrar/Registrar.java @@ -619,6 +619,7 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable .putListOfStrings("allowedTlds", getAllowedTlds()) .putListOfStrings("ipAddressWhitelist", ipAddressWhitelist) .putListOfJsonObjects("contacts", getContacts()) + .put("registryLockAllowed", registryLockAllowed) .build(); } diff --git a/core/src/main/java/google/registry/model/registrar/RegistrarContact.java b/core/src/main/java/google/registry/model/registrar/RegistrarContact.java index 40279f84a..4c1b37476 100644 --- a/core/src/main/java/google/registry/model/registrar/RegistrarContact.java +++ b/core/src/main/java/google/registry/model/registrar/RegistrarContact.java @@ -314,6 +314,7 @@ public class RegistrarContact extends ImmutableObject implements Jsonifiable { .put("visibleInWhoisAsTech", visibleInWhoisAsTech) .put("visibleInDomainWhoisAsAbuse", visibleInDomainWhoisAsAbuse) .put("allowedToSetRegistryLockPassword", allowedToSetRegistryLockPassword) + .put("registryLockAllowed", isRegistryLockAllowed()) .put("gaeUserId", gaeUserId) .build(); } diff --git a/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java b/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java index ccb26e398..65130f5d4 100644 --- a/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java +++ b/core/src/main/java/google/registry/ui/server/RegistrarFormFields.java @@ -202,8 +202,13 @@ public final class RegistrarFormFields { .build(); public static final FormField CONTACT_GAE_USER_ID_FIELD = - FormFields.NAME.asBuilderNamed("gaeUserId") - .build(); + FormFields.NAME.asBuilderNamed("gaeUserId").build(); + + public static final FormField CONTACT_ALLOWED_TO_SET_REGISTRY_LOCK_PASSWORD = + FormField.named("allowedToSetRegistryLockPassword", Boolean.class).build(); + + public static final FormField CONTACT_REGISTRY_LOCK_PASSWORD_FIELD = + FormFields.NAME.asBuilderNamed("registryLockPassword").build(); public static final FormField> CONTACT_TYPES = FormField.named("types") @@ -360,6 +365,12 @@ public final class RegistrarFormFields { CONTACT_FAX_NUMBER_FIELD.extractUntyped(args).ifPresent(builder::setFaxNumber); CONTACT_TYPES.extractUntyped(args).ifPresent(builder::setTypes); CONTACT_GAE_USER_ID_FIELD.extractUntyped(args).ifPresent(builder::setGaeUserId); + CONTACT_ALLOWED_TO_SET_REGISTRY_LOCK_PASSWORD + .extractUntyped(args) + .ifPresent(builder::setAllowedToSetRegistryLockPassword); + CONTACT_REGISTRY_LOCK_PASSWORD_FIELD + .extractUntyped(args) + .ifPresent(builder::setRegistryLockPassword); return builder; } } diff --git a/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java b/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java index 4a4e68c6c..a8e201a97 100644 --- a/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java +++ b/core/src/main/java/google/registry/ui/server/registrar/RegistrarSettingsAction.java @@ -438,6 +438,25 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA throw new ContactRequirementException( "An abuse contact visible in domain WHOIS query must be designated"); } + + // Any contact(s) with new passwords must be allowed to set them + for (RegistrarContact updatedContact : updatedContacts) { + if (updatedContact.isRegistryLockAllowed() + || updatedContact.isAllowedToSetRegistryLockPassword()) { + RegistrarContact existingContact = + existingContacts.stream() + .filter( + contact -> contact.getEmailAddress().equals(updatedContact.getEmailAddress())) + .findFirst() + .orElseThrow( + () -> + new FormException( + "Not allowed to set registry lock password directly on new contact")); + if (!existingContact.isAllowedToSetRegistryLockPassword()) { + throw new FormException("Registrar contact not allowed to set registry lock password"); + } + } + } } /** diff --git a/core/src/main/javascript/google/registry/ui/externs/json.js b/core/src/main/javascript/google/registry/ui/externs/json.js index d429ec64a..475e3a654 100644 --- a/core/src/main/javascript/google/registry/ui/externs/json.js +++ b/core/src/main/javascript/google/registry/ui/externs/json.js @@ -117,7 +117,8 @@ registry.json.Response.prototype.results; * localizedAddress: registry.json.RegistrarAddress, * whoisServer: (string?|undefined), * referralUrl: (string?|undefined), - * contacts: !Array. + * contacts: !Array., + * registryLockAllowed: boolean * }} */ registry.json.Registrar; @@ -144,7 +145,9 @@ registry.json.RegistrarAddress; * visibleInDomainWhoisAsAbuse: boolean, * phoneNumber: (string?|undefined), * faxNumber: (string?|undefined), - * types: (string?|undefined) + * types: (string?|undefined), + * allowedToSetRegistryLockPassword: boolean, + * registryLockAllowed: boolean * }} */ registry.json.RegistrarContact; diff --git a/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js b/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js index a09a85a36..03bdd2307 100644 --- a/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js +++ b/core/src/main/javascript/google/registry/ui/js/registrar/contact_settings.js @@ -102,7 +102,8 @@ registry.registrar.ContactSettings.prototype.renderItem = function(rspObj) { item: targetContact, namePrefix: 'contacts[' + targetContactNdx + '].', actualTypesLookup: actualTypesLookup, - readonly: (rspObj.readonly || false) + readonly: (rspObj.readonly || false), + registryLockAllowedForRegistrar: rspObj.registryLockAllowed }); this.setupAppbar(); } else { diff --git a/core/src/main/resources/google/registry/ui/soy/Forms.soy b/core/src/main/resources/google/registry/ui/soy/Forms.soy index dd424b1df..992cbd033 100644 --- a/core/src/main/resources/google/registry/ui/soy/Forms.soy +++ b/core/src/main/resources/google/registry/ui/soy/Forms.soy @@ -53,6 +53,8 @@ {@param? description: ?} /** Input field description. */ {@param? placeholder: ?} /** Placeholder text. */ {@param? readonly: ?} + {@param? disabled: ?} + {@param? isPassword: ?}