Updated code
This commit is contained in:
@@ -222,21 +222,23 @@ public class UserDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateDuplicateEmail(String email, String hubUuid, String roleType) {
|
private void validateDuplicateEmail(String email, String hubUuid, String roleType) {
|
||||||
Boolean existsForNonBeneficiaries = userRepository.existsByEmailIgnoreCaseForNonBeneficiaries(
|
String beneficiaryRoleType = RoleStatusEnum.ROLE_BENEFICIARY.getValue();
|
||||||
email, hubUuid, RoleStatusEnum.ROLE_BENEFICIARY.getValue());
|
|
||||||
|
|
||||||
Boolean beneficiaryExistsInHub = userRepository.existsByEmailIgnoreCaseForBeneficiaries(
|
if (beneficiaryRoleType.equals(roleType)) {
|
||||||
email, hubUuid, RoleStatusEnum.ROLE_BENEFICIARY.getValue());
|
Boolean beneficiaryExistsInHub = userRepository.existsByEmailIgnoreCaseForBeneficiaries(
|
||||||
|
email, hubUuid, beneficiaryRoleType);
|
||||||
|
|
||||||
if (Boolean.TRUE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleType))) {
|
if (Boolean.TRUE.equals(beneficiaryExistsInHub)) {
|
||||||
if (beneficiaryExistsInHub) {
|
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
Boolean existsForNonBeneficiaries = userRepository.existsByEmailIgnoreCaseForNonBeneficiaries(
|
||||||
if (existsForNonBeneficiaries) {
|
email, hubUuid, beneficiaryRoleType);
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(existsForNonBeneficiaries)) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
Translator.toLocale(GepafinConstant.EMAIL_ALREADY_EXISTS));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,24 +33,28 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
|||||||
|
|
||||||
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
Optional<UserEntity> findByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||||
|
|
||||||
Boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
// Boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||||
|
|
||||||
@Query("SELECT COUNT(u) > 0 " +
|
@Query("SELECT COUNT(u) > 0 " +
|
||||||
"FROM UserEntity u " +
|
"FROM UserEntity u " +
|
||||||
"WHERE u.email = :email " +
|
"WHERE LOWER(u.email) = LOWER(:email) " +
|
||||||
"AND u.hub.uniqueUuid = :hubUuid " +
|
"AND u.hub.uniqueUuid = :hubUuid " +
|
||||||
"AND u.roleEntity.roleType <> :beneficiaryRoleType")
|
"AND u.roleEntity.roleType <> :beneficiaryRoleType")
|
||||||
Boolean existsByEmailIgnoreCaseForNonBeneficiaries(@Param("email") String email,
|
Boolean existsByEmailIgnoreCaseForNonBeneficiaries(@Param("email") String email,
|
||||||
@Param("hubUuid") String hubUuid,
|
@Param("hubUuid") String hubUuid,
|
||||||
@Param("beneficiaryRoleType") String beneficiaryRoleType);
|
@Param("beneficiaryRoleType") String beneficiaryRoleType);
|
||||||
|
|
||||||
@Query("SELECT CASE WHEN COUNT(u) > 0 THEN true ELSE false END " +
|
@Query("SELECT COUNT(u) > 0 " +
|
||||||
"FROM UserEntity u " +
|
"FROM UserEntity u " +
|
||||||
"WHERE LOWER(u.email) = LOWER(:email) AND u.hub.uniqueUuid = :hubUuid " +
|
"WHERE LOWER(u.email) = LOWER(:email) " +
|
||||||
"AND u.roleEntity.roleType = :beneficiaryRoleType")
|
"AND u.hub.uniqueUuid = :hubUuid " +
|
||||||
Boolean existsByEmailIgnoreCaseForBeneficiaries(String email, String hubUuid, String beneficiaryRoleType);
|
"AND u.roleEntity.roleType = :beneficiaryRoleType")
|
||||||
|
Boolean existsByEmailIgnoreCaseForBeneficiaries(@Param("email") String email,
|
||||||
|
@Param("hubUuid") String hubUuid,
|
||||||
|
@Param("beneficiaryRoleType") String beneficiaryRoleType);
|
||||||
|
|
||||||
// existsByBebooleanneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
|
||||||
|
boolean existsByBeneficiaryCodiceFiscaleAndHubId(String codiceFiscale, Long hubId);
|
||||||
|
|
||||||
List<UserEntity> findByRoleEntity_RoleTypeAndHubId(String roleType, Long hubId);
|
List<UserEntity> findByRoleEntity_RoleTypeAndHubId(String roleType, Long hubId);
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,7 @@ VALUES
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<p style="margin: 8px 0px;">Gentile {{user_name}},</p>
|
<p style="margin: 8px 0px;">Gentile {{user_name}},</p>
|
||||||
<p style="margin: 8px 0px;">Hai richiesto di reimpostare la tua password. Puoi farlo cliccando sul link sottostante:</p>
|
<p style="margin: 8px 0px;">Hai richiesto di reimpostare la tua password.</p>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<a href="{{reset_password_link}}" style="color: #007bff; text-decoration: none; margin: 8px 0px;" target="_blank">{{reset_password_link}}</a>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user