Skip to content

Commit a997113

Browse files
committed
Fix NPe
1 parent 08e0d86 commit a997113

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,14 +481,18 @@ public ModelAndView viewDeactivateOrcidAccount() {
481481
public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, HttpServletResponse response, @PathVariable("encryptedEmail") String encryptedEmail) throws Exception {
482482
ModelAndView result = null;
483483
String decryptedEmail = encryptionManager.decryptForExternalUse(new String(Base64.decodeBase64(encryptedEmail), "UTF-8"));
484-
String primaryEmail = emailManager.findPrimaryEmail(getCurrentUserOrcid()).getEmail();
484+
String currentUserOrcid = getCurrentUserOrcid();
485485

486-
if (decryptedEmail.equals(primaryEmail)) {
487-
profileEntityManager.deactivateRecord(getCurrentUserOrcid());
488-
logoutCurrentUser(request, response);
489-
result = new ModelAndView("redirect:" + calculateRedirectUrl("/signin#deactivated"));
490-
} else {
491-
return new ModelAndView("redirect:"+ calculateRedirectUrl("/my-orcid"));
486+
if(!PojoUtil.isEmpty(currentUserOrcid)) {
487+
org.orcid.jaxb.model.v3.release.record.Email primaryEmail = emailManager.findPrimaryEmail(currentUserOrcid);
488+
489+
if (primaryEmail != null && decryptedEmail.equals(primaryEmail.getEmail())) {
490+
profileEntityManager.deactivateRecord(currentUserOrcid);
491+
logoutCurrentUser(request, response);
492+
result = new ModelAndView("redirect:" + calculateRedirectUrl("/signin#deactivated"));
493+
} else {
494+
return new ModelAndView("redirect:" + calculateRedirectUrl("/my-orcid"));
495+
}
492496
}
493497

494498
return result;

0 commit comments

Comments
 (0)