diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java index e3e99fb1b3f..f743785b496 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java @@ -536,7 +536,17 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht if (Features.EMAIL_DOMAINS.isActive()) { emailDomains = profileEmailDomainManagerReadOnly.getEmailDomains(getCurrentUserOrcid()); } - return org.orcid.pojo.ajaxForm.Emails.valueOf(v2Emails, emailDomains); + org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(v2Emails, emailDomains); + // Old emails are missing the source name and id -- assign the user as the source + for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) { + if (email.getSource() == null && email.getSourceName() == null) { + String orcid = getCurrentUserOrcid(); + String displayName = getPersonDetails(orcid, true).getDisplayName(); + email.setSource(orcid); + email.setSourceName(displayName); + } + } + return emails; } @RequestMapping(value = "/emails.json", method = RequestMethod.POST) diff --git a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java index feb81265199..b0787513446 100644 --- a/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java +++ b/orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java @@ -202,8 +202,16 @@ PublicRecord getRecord(String orcid) { if (Features.EMAIL_DOMAINS.isActive()) { emailDomains = profileEmailDomainManagerReadOnly.getPublicEmailDomains(orcid); } - - publicRecord.setEmails(org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails, emailDomains)); + + org.orcid.pojo.ajaxForm.Emails emails = org.orcid.pojo.ajaxForm.Emails.valueOf(filteredEmails, emailDomains); + // Old emails are missing the source name and id -- assign the user as the source + for (org.orcid.pojo.ajaxForm.Email email: emails.getEmails()) { + if (email.getSource() == null && email.getSourceName() == null) { + email.setSource(orcid); + email.setSourceName(publicRecord.getDisplayName()); + } + } + publicRecord.setEmails(emails); // Fill external identifiers PersonExternalIdentifiers publicPersonExternalIdentifiers;