Done ticket GEPAFINBE-183
This commit is contained in:
@@ -490,6 +490,9 @@ public class GepafinConstant {
|
||||
|
||||
public static final String REGION_ID="regionId";
|
||||
|
||||
public static final String EMAIL_SUPPORT = "email_support";
|
||||
public static final String PHONE_SUPPORT = "phone_support";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -40,10 +40,8 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
@@ -78,6 +76,12 @@ public class UserDao {
|
||||
@Value("${default.hub.uuid}")
|
||||
private String defaultHubUuid;
|
||||
|
||||
@Value("${app.confidi.login.url.suffix}")
|
||||
private String confidiLogin;
|
||||
|
||||
@Value("${app.bandi.login.url.suffix}")
|
||||
private String bandiLoginUrlSuffix;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@@ -139,35 +143,57 @@ public class UserDao {
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).newData(userEntity).build());
|
||||
|
||||
if(beneficiary == null){
|
||||
sendEmailToOnboardingUser(userEntity);
|
||||
sendEmailToOnboardingUser(userEntity, userReq );
|
||||
}
|
||||
return token;
|
||||
}
|
||||
public void sendEmailToOnboardingUser(UserEntity userEntity){
|
||||
SystemEmailTemplateResponse emailTemplate = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(
|
||||
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.USER_ONBOARDING, userEntity.getHub(), null);
|
||||
public void sendEmailToOnboardingUser(UserEntity userEntity,UserReq userReq){
|
||||
SystemEmailTemplateResponse emailTemplate;
|
||||
RoleStatusEnum roleStatus = RoleStatusEnum.valueOf(userEntity.getRoleEntity().getRoleType());
|
||||
|
||||
SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum templateType =
|
||||
roleStatus.equals(RoleStatusEnum.ROLE_CONFIDI)
|
||||
? SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.USER_ONBOARDING_CONFIDI
|
||||
: SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum.USER_ONBOARDING_BANDI;
|
||||
|
||||
emailTemplate = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(templateType, userEntity.getHub(), null);
|
||||
|
||||
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(emailTemplate.getEmailScenario(), RecipientTypeEnum.USER, userEntity.getId(), userEntity.getEmail(),
|
||||
userEntity.getId(), null, null, null);
|
||||
String firstName = userEntity.getFirstName() != null ? userEntity.getFirstName() : "";
|
||||
String lastName = userEntity.getLastName() != null ? userEntity.getLastName() : "";
|
||||
String userName = String.join(" ", firstName, lastName).trim();
|
||||
String subject = Utils.replacePlaceholders(emailTemplate.getSubject(), Map.of(
|
||||
"{{user_name}}", userName
|
||||
));
|
||||
String body = Utils.replacePlaceholders(emailTemplate.getHtmlContent(), Map.of(
|
||||
"{{user_name}}", userName,
|
||||
"{{user_email}}", userEntity.getEmail()
|
||||
));
|
||||
|
||||
Map<String, String> placeholders = replacePlaceholders(userEntity, userReq);
|
||||
String body = Utils.replacePlaceholders(emailTemplate.getHtmlContent(), placeholders);
|
||||
|
||||
emailNotificationDao.sendMail(
|
||||
userEntity.getHub().getId(),
|
||||
subject,
|
||||
emailTemplate.getSubject(),
|
||||
body,
|
||||
List.of(userEntity.getEmail()),
|
||||
emailLogRequest
|
||||
);
|
||||
}
|
||||
private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq, HubEntity hub) {
|
||||
|
||||
private Map<String, String> replacePlaceholders(UserEntity userEntity, UserReq userReq) {
|
||||
RoleStatusEnum roleStatus = RoleStatusEnum.valueOf(userEntity.getRoleEntity().getRoleType());
|
||||
String confidiLoginUrl = userEntity.getHub().getDomainName() + confidiLogin;
|
||||
String bandiLoginUrl = userEntity.getHub().getDomainName() + bandiLoginUrlSuffix;
|
||||
String hubConfigText = userEntity.getHub().getHubConfig();
|
||||
JSONObject hubConfig = new JSONObject(hubConfigText);
|
||||
|
||||
String gepafinEmail = hubConfig.optString(GepafinConstant.EMAIL_SUPPORT, "");
|
||||
String gepafinPhoneNumber = hubConfig.optString(GepafinConstant.PHONE_SUPPORT, "");
|
||||
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("{{username}}", userEntity.getEmail());
|
||||
placeholders.put("{{userpassword}}",userReq.getPassword());
|
||||
String loginUrl = roleStatus.equals(RoleStatusEnum.ROLE_CONFIDI) ? confidiLoginUrl : bandiLoginUrl;
|
||||
placeholders.put("{{login_url}}",loginUrl);
|
||||
placeholders.put("{{gepafinphonenumber}}", gepafinPhoneNumber);
|
||||
placeholders.put("{{gepafinemail}}", gepafinEmail);
|
||||
return placeholders;
|
||||
}
|
||||
|
||||
private BeneficiaryEntity createBeneficiary(RoleEntity roleEntity, UserReq userReq, HubEntity hub) {
|
||||
BeneficiaryEntity beneficiaryEntity = null;
|
||||
if (RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType())) {
|
||||
beneficiaryEntity = new BeneficiaryEntity();
|
||||
|
||||
@@ -66,4 +66,7 @@ public class HubEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "EVALUATION_EXPIRATION_DAYS")
|
||||
private Long evaluationExpirationDays;
|
||||
|
||||
@Column(name = "HUB_CONFIG")
|
||||
private String hubConfig;
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ public class SystemEmailTemplatesEntity extends BaseEntity {
|
||||
INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE("INADMISSIBILITY_NOTIFICATION_DUE_TO_FAILURE"),
|
||||
ADMISSIBILITY_NOTIFICATION("ADMISSIBILITY_NOTIFICATION"),
|
||||
AMENDMENT_REMINDER("AMENDMENT_REMINDER"),
|
||||
USER_ONBOARDING("USER_ONBOARDING"),
|
||||
USER_ONBOARDING_CONFIDI("USER_ONBOARDING_CONFIDI"),
|
||||
USER_ONBOARDING_BANDI("USER_ONBOARDING_BANDI"),
|
||||
PASSWORD_RESET("PASSWORD_RESET"),
|
||||
INADMISSIBILITY_TEMPLATE("INADMISSIBILITY_NOTIFICATION");
|
||||
|
||||
private String value;
|
||||
|
||||
SystemEmailTemplatesEntityTypeEnum(String value) {
|
||||
|
||||
@@ -69,3 +69,6 @@ default.hub.pdf.banner=https://mementoresources.s3.amazonaws.com/gepafin/staging
|
||||
spring.cloud.openfeign.client.config.default.connectTimeout=300000
|
||||
spring.cloud.openfeign.client.config.default.readTimeout=300000
|
||||
spring.rabbitmq.connection-timeout=120000
|
||||
|
||||
app.bandi.login.url.suffix=/loginadmin
|
||||
app.confidi.login.url.suffix=/confidi
|
||||
@@ -2621,4 +2621,25 @@
|
||||
</insert>
|
||||
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="13-03-2025_PK_121745" author="Piyush Kag">
|
||||
<addColumn tableName="hub">
|
||||
<column name="hub_config" type="TEXT"/>
|
||||
</addColumn>
|
||||
|
||||
<sqlFile dbms="postgresql" path="db/dump/update_hub_data_for_hub_config_13-03-2025.sql"/>
|
||||
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_system_email_template_for_confidi_user_13-03-2025.sql"/>
|
||||
|
||||
<sql dbms="postgresql">select
|
||||
setval('gepafin_schema.system_email_template_id_seq', (select
|
||||
max(id)+1
|
||||
from gepafin_schema.system_email_template), false)
|
||||
</sql>
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/insert_system_email_template_for_user_13-03-2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
INSERT INTO gepafin_schema.system_email_template
|
||||
(template_name, "type", html_content, subject, "json", "system", is_deleted, created_date, updated_date, email_scenario)
|
||||
VALUES
|
||||
(
|
||||
'Welcome Email for New Bandi User',
|
||||
'USER_ONBOARDING_BANDI',
|
||||
'<html>
|
||||
<body style="font-family: Arial, sans-serif; color: #000; line-height: 1.6;">
|
||||
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
|
||||
<p><strong>Gentile Utente,</strong></p>
|
||||
<p>Le comunichiamo che il Suo account per accedere al portale è stato creato con successo.</p>
|
||||
<p><strong>Di seguito trova le credenziali di accesso:</strong></p>
|
||||
<ul>
|
||||
<li><strong>Indirizzo portale:</strong> <a href="{{login_url}}">{{login_url}}</a></li>
|
||||
<li><strong>Nome utente:</strong> {{username}}</li>
|
||||
<li><strong>Password:</strong> {{userpassword}}</li>
|
||||
</ul>
|
||||
<p>Al primo accesso le consigliamo di modificare la password con una nuova di Sua scelta.
|
||||
Per motivi di sicurezza, Le consigliamo di scegliere una password che:</p>
|
||||
<ul>
|
||||
<li>Sia composta da almeno 8 caratteri</li>
|
||||
<li>Contenga lettere maiuscole e minuscole</li>
|
||||
<li>Includa numeri e caratteri speciali</li>
|
||||
</ul>
|
||||
<p>In caso di difficoltà durante laccesso o per qualsiasi chiarimento, può contattare il nostro servizio di assistenza:</p>
|
||||
<ul>
|
||||
<li>Email: <a href="mailto:{{gepafinemail}}">{{gepafinemail}}</a></li>
|
||||
<li>Telefono: {{gepafinphonenumber}}</li>
|
||||
</ul>
|
||||
<p>La invitiamo a conservare queste informazioni in un luogo sicuro e a non condividerle con terzi.</p>
|
||||
<p>Cordiali saluti,</p>
|
||||
<p><strong>{{email_signature}}</strong></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>',
|
||||
'Le Sue Credenziali di Accesso al Portale Bandi',
|
||||
NULL,
|
||||
true,
|
||||
false,
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP,
|
||||
'USER_CREATION'
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
UPDATE hub
|
||||
SET hub_config = '{"email_support": "", "phone_support": ""}'
|
||||
WHERE unique_uuid = 't7jh5wfg9QXylNaTZkPoE';
|
||||
|
||||
-- Update hub table with specific email and phone support values
|
||||
UPDATE hub
|
||||
SET hub_config = '{"email_support": "email@support.it", "phone_support": "09998888"}'
|
||||
WHERE unique_uuid = 'p4lk3bcx1RStqTaIVVbXs';
|
||||
@@ -0,0 +1,38 @@
|
||||
UPDATE gepafin_schema.system_email_template
|
||||
SET
|
||||
template_name = 'Welcome Email for New Confidi User',
|
||||
"type" = 'USER_ONBOARDING_CONFIDI',
|
||||
html_content = '<html>
|
||||
<body style="font-family: Arial, sans-serif; color: #000; line-height: 1.6;">
|
||||
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
|
||||
<p><strong>Gentile Utente,</strong></p>
|
||||
<p>Le comunichiamo che il Suo account per accedere al portale è stato creato con successo.</p>
|
||||
<p><strong>Di seguito trova le credenziali di accesso:</strong></p>
|
||||
<wul>
|
||||
<li><strong>Indirizzo portale:</strong> <a href="{{login_url}}">{{login_url}}</a></li>
|
||||
<li><strong>Nome utente:</strong> {{username}}</li>
|
||||
<li><strong>Password:</strong> {{userpassword}}</li>
|
||||
</ul>
|
||||
<p>Al primo accesso le consigliamo di modificare la password con una nuova di Sua scelta.
|
||||
Per motivi di sicurezza, Le consigliamo di scegliere una password che:</p>
|
||||
<ul>
|
||||
<li>Sia composta da almeno 8 caratteri</li>
|
||||
<li>Contenga lettere maiuscole e minuscole</li>
|
||||
<li>Includa numeri e caratteri speciali</li>
|
||||
</ul>
|
||||
<p>In caso di difficoltà durante laccesso o per qualsiasi chiarimento, può contattare il nostro servizio di assistenza:</p>
|
||||
<ul>
|
||||
<li>Email: <a href="mailto:{{gepafinemail}}">{{gepafinemail}}</a></li>
|
||||
<li>Telefono: {{gepafinphonenumber}}</li>
|
||||
</ul>
|
||||
<p>La invitiamo a conservare queste informazioni in un luogo sicuro e a non condividerle con terzi.</p>
|
||||
<p>Cordiali saluti,</p>
|
||||
<p><strong>{{email_signature}}</strong></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>',
|
||||
subject = 'Le Sue Credenziali di Accesso al Portale Gepafin Confidi',
|
||||
updated_date = CURRENT_TIMESTAMP
|
||||
WHERE template_name = 'Welcome Email for New User' AND "type" = 'USER_ONBOARDING';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user