In the gerrit 3.11.3 settings, users can delete emails if they are not marked as "preferred".
This prevents users from deleting their last remaining email address, and thus prevents them from breaking their account.
The "preferred" email address can still be removed indirectly, in our case by deleting the associated "Identity" in the "Identities" section of the gerrit settings.
After a "preferred" email address is deleted in such a way, no email address is marked as "preferred, which allows the user to delete all their email addresses...
and of course some of them will do so... *sigh*
I assume that the method "unlink" in
gerrit/java/com/google/gerrit/server/account/AccountManager.java
handles the deletion of emails.
The code looks like this:
>>>>>
accountsUpdateProvider
.get()
.update(
"Unlink External ID" + (extIds.size() > 1 ? "s" : ""),
from,
(a, u) -> {
u.deleteExternalIds(extIds);
if (a.account().preferredEmail() != null
&& extIds.stream()
.anyMatch(e -> a.account().preferredEmail().equals(e.email()))) {
u.setPreferredEmail(null);
}
});
<<<<<
Instead of setting the preferred email to null at this place, the code could mark one of the remaining email addresses (eg, the first one in the list) as preferred.
Thanks, Fabian.