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,6 +69,7 @@ public class MergeEmailConfirmationManager {
public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) throws HasConfirmedEmailException { public void sendConfirmationEmail(String email, Principal principal, UUID userId, Integer provider) throws HasConfirmedEmailException {
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId()); UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
if (user.getEmail() != null && !user.getEmail().equals(email)) {
apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail( apiContext.getUtilitiesService().getConfirmationEmailService().createMergeConfirmationEmail(
databaseRepository.getLoginConfirmationEmailDao(), databaseRepository.getLoginConfirmationEmailDao(),
apiContext.getUtilitiesService().getMailService(), apiContext.getUtilitiesService().getMailService(),
@ -78,6 +79,7 @@ public class MergeEmailConfirmationManager {
provider provider
); );
} }
}
@Transactional @Transactional
private void mergeNewUserToOld(UserInfo newUser, UserInfo oldUser, Integer provider) { private void mergeNewUserToOld(UserInfo newUser, UserInfo oldUser, Integer provider) {