mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 08:27:14 +02:00
Fix registrar security console
The registrar security console failed because it assumed the email is a required field for the registrar, but it isn't (at least - create_registrar doesn't require an email, and update_registrar lets you remove the email). Fixed by allowing it to *remain* unset if it was unset originally, but if it was set - it's required. There are more fixes needed, but they aren't related to the email, so they will wait for the next CL ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=191623034
This commit is contained in:
parent
e816913c61
commit
ea891001d9
7 changed files with 44 additions and 14 deletions
|
@ -71,12 +71,17 @@ public final class RegistrarFormFields {
|
|||
.required()
|
||||
.build();
|
||||
|
||||
public static final FormField<String, String> EMAIL_ADDRESS_FIELD =
|
||||
public static final FormField<String, String> EMAIL_ADDRESS_FIELD_REQUIRED =
|
||||
FormFields.EMAIL.asBuilderNamed("emailAddress")
|
||||
.matches(ASCII_PATTERN, ASCII_ERROR)
|
||||
.required()
|
||||
.build();
|
||||
|
||||
public static final FormField<String, String> EMAIL_ADDRESS_FIELD_OPTIONAL =
|
||||
FormFields.EMAIL.asBuilderNamed("emailAddress")
|
||||
.matches(ASCII_PATTERN, ASCII_ERROR)
|
||||
.build();
|
||||
|
||||
public static final FormField<String, String> ICANN_REFERRAL_EMAIL_FIELD =
|
||||
FormFields.EMAIL.asBuilderNamed("icannReferralEmail")
|
||||
.matches(ASCII_PATTERN, ASCII_ERROR)
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
|
|||
import static google.registry.security.JsonResponseHelper.Status.ERROR;
|
||||
import static google.registry.security.JsonResponseHelper.Status.SUCCESS;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -125,14 +126,14 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
|||
initialRegistrar.getClientId(),
|
||||
args);
|
||||
return JsonResponseHelper.createFormFieldError(e.getMessage(), e.getFieldName());
|
||||
} catch (FormException ee) {
|
||||
} catch (FormException e) {
|
||||
logger.warningfmt(
|
||||
ee,
|
||||
e,
|
||||
"Failed to perform operation '%s' on registrar '%s' for args %s",
|
||||
op,
|
||||
initialRegistrar.getClientId(),
|
||||
args);
|
||||
return JsonResponseHelper.create(ERROR, ee.getMessage());
|
||||
return JsonResponseHelper.create(ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -196,7 +197,12 @@ public class RegistrarSettingsAction implements Runnable, JsonActionRunner.JsonA
|
|||
RegistrarFormFields.WHOIS_SERVER_FIELD.extractUntyped(args).orElse(null));
|
||||
builder.setReferralUrl(
|
||||
RegistrarFormFields.REFERRAL_URL_FIELD.extractUntyped(args).orElse(null));
|
||||
RegistrarFormFields.EMAIL_ADDRESS_FIELD
|
||||
|
||||
// If the email is already null / empty - we can keep it so. But if it's set - it's required to
|
||||
// remain set.
|
||||
(Strings.isNullOrEmpty(existingRegistrarObj.getEmailAddress())
|
||||
? RegistrarFormFields.EMAIL_ADDRESS_FIELD_OPTIONAL
|
||||
: RegistrarFormFields.EMAIL_ADDRESS_FIELD_REQUIRED)
|
||||
.extractUntyped(args)
|
||||
.ifPresent(builder::setEmailAddress);
|
||||
builder.setPhoneNumber(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue