1
0
mirror of https://github.com/google/nomulus synced 2026-06-09 16:33:02 +00:00

Flat-map registry lock emails to avoid unclean errors in bad situations (#525)

* Flat map to avoid unclean errors in bad situations

Also properly reflect that for admins, we will use their user email

* Make MS's GAE user ID a public static field
This commit is contained in:
gbrodman
2020-03-23 11:45:49 -04:00
committed by GitHub
parent fa9400ebc5
commit ad06f265a5
5 changed files with 8 additions and 6 deletions

View File

@@ -159,9 +159,10 @@ public final class RegistryLockGetAction implements JsonGetAction {
isAdmin || contactOptional.map(RegistrarContact::isRegistryLockAllowed).orElse(false);
// Use the contact's registry lock email if it's present, else use the login email (for admins)
String relevantEmail =
contactOptional
.map(contact -> contact.getRegistryLockEmailAddress().get())
.orElse(user.getEmail());
isAdmin
? user.getEmail()
// if the contact isn't present, we shouldn't display the email anyway so empty is fine
: contactOptional.flatMap(RegistrarContact::getRegistryLockEmailAddress).orElse("");
return ImmutableMap.of(
LOCK_ENABLED_FOR_CONTACT_PARAM,
isRegistryLockAllowed,