diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/AdminController.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/AdminController.java index c135571b..0e835d19 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/AdminController.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/AdminController.java @@ -141,7 +141,9 @@ public class AdminController extends AbstractDnetController { public SystemConfiguration saveSysConf(@RequestBody final SystemConfiguration sysConf, final Authentication authentication) { if (UserInfo.isSuperAdmin(authentication)) { sysConf.setId(SystemConfiguration.DEFAULT_ID); - return systemConfigurationRepository.save(sysConf); + systemConfigurationRepository.save(sysConf); + mailDispatcher.configure(sysConf); + return sysConf; } else { throw new RuntimeException("User not authorized"); } diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/UserInfo.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/UserInfo.java index 5ee4ae67..f05114a1 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/UserInfo.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/controller/UserInfo.java @@ -113,7 +113,7 @@ public class UserInfo { } public static String getOrganization(final OidcUser user) { - return user.getAttribute("organization"); + return StringUtils.firstNonBlank(user.getAttribute("organization"), user.getAttribute("affiliation")); } } diff --git a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/MailDispatcher.java b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/MailDispatcher.java index 110ab35a..f79a29bc 100644 --- a/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/MailDispatcher.java +++ b/apps/dnet-orgs-database-application/src/main/java/eu/dnetlib/organizations/utils/MailDispatcher.java @@ -37,9 +37,11 @@ public class MailDispatcher { @PostConstruct public void configure() { - final SystemConfiguration conf = systemConfigurationRepository.findById(SystemConfiguration.DEFAULT_ID).get(); + configure(conf); + } + public void configure(final SystemConfiguration conf) { this.enabled = conf.getSmtpEnabled(); this.fromMail = conf.getSmtpFromMail(); this.fromName = conf.getSmtpFromName();