Prevent user to send merge request email to itself

This commit is contained in:
George Kalampokis 2020-11-10 17:39:43 +02:00
parent 5d01519415
commit f5533e1b95
1 changed files with 10 additions and 8 deletions

View File

@ -69,14 +69,16 @@ public class MergeEmailConfirmationManager {
public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) throws HasConfirmedEmailException {
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail(
databaseRepository.getLoginConfirmationEmailDao(),
apiContext.getUtilitiesService().getMailService(),
email,
userId,
principal,
provider
);
if (user.getEmail() != null && !user.getEmail().equals(email)) {
apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail(
databaseRepository.getLoginConfirmationEmailDao(),
apiContext.getUtilitiesService().getMailService(),
email,
userId,
principal,
provider
);
}
}
@Transactional