From 1271f9cf43a6da3b4346dac568161fcb6c1d2c8d Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Fri, 23 Sep 2022 08:22:00 +0200 Subject: [PATCH] little changes --- .../eu/dnetlib/organizations/controller/AdminController.java | 4 +++- .../java/eu/dnetlib/organizations/controller/UserInfo.java | 2 +- .../java/eu/dnetlib/organizations/utils/MailDispatcher.java | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) 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();