|
|
|
@ -536,9 +536,6 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
fieldInfoList.add(new FieldInfo("{userName}", DataType.String, currentUser.getName()));
|
|
|
|
|
fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, token));
|
|
|
|
|
fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(this.notificationProperties.getEmailExpirationTimeSeconds())));
|
|
|
|
|
if(this.tenantScope.getTenantCode() != null && !this.tenantScope.getTenantCode().equals(this.tenantScope.getDefaultTenantCode())){
|
|
|
|
|
fieldInfoList.add(new FieldInfo("{tenant-url-path}", DataType.String, String.format("/t/%s", this.tenantScope.getTenantCode())));
|
|
|
|
|
}
|
|
|
|
|
data.setFields(fieldInfoList);
|
|
|
|
|
event.setData(this.jsonHandlingService.toJsonSafe(data));
|
|
|
|
|
this.eventHandler.handle(event);
|
|
|
|
@ -563,9 +560,6 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
List<FieldInfo> fieldInfoList = new ArrayList<>();
|
|
|
|
|
fieldInfoList.add(new FieldInfo("{confirmationToken}", DataType.String, token));
|
|
|
|
|
fieldInfoList.add(new FieldInfo("{expiration_time}", DataType.String, this.secondsToTime(this.notificationProperties.getEmailExpirationTimeSeconds())));
|
|
|
|
|
if(this.tenantScope.getTenantCode() != null && !this.tenantScope.getTenantCode().equals(this.tenantScope.getDefaultTenantCode())){
|
|
|
|
|
fieldInfoList.add(new FieldInfo("{tenant-url-path}", DataType.String, String.format("/t/%s", this.tenantScope.getTenantCode())));
|
|
|
|
|
}
|
|
|
|
|
data.setFields(fieldInfoList);
|
|
|
|
|
event.setData(this.jsonHandlingService.toJsonSafe(data));
|
|
|
|
|
this.eventHandler.handle(event);
|
|
|
|
@ -579,9 +573,14 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
persist.setMergeAccountConfirmation(new MergeAccountConfirmationPersist());
|
|
|
|
|
persist.getMergeAccountConfirmation().setEmail(email);
|
|
|
|
|
persist.setExpiresAt(Instant.now().plusSeconds(this.notificationProperties.getEmailExpirationTimeSeconds()));
|
|
|
|
|
this.validatorFactory.validator(ActionConfirmationPersist.ActionConfirmationPersistValidator.class).validateForce(persist);
|
|
|
|
|
this.validatorFactory.validator(ActionConfirmationPersist.ActionConfirmationPersistValidator.class).validateForce(persist);
|
|
|
|
|
this.actionConfirmationService.persist(persist, null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
this.entityManager.disableTenantFilters();
|
|
|
|
|
} finally {
|
|
|
|
|
this.entityManager.reloadTenantFilters();
|
|
|
|
|
}
|
|
|
|
|
return persist.getToken();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -593,9 +592,13 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
persist.setRemoveCredentialRequest(new RemoveCredentialRequestPersist());
|
|
|
|
|
persist.getRemoveCredentialRequest().setCredentialId(credentialId);
|
|
|
|
|
persist.setExpiresAt(Instant.now().plusSeconds(this.notificationProperties.getEmailExpirationTimeSeconds()));
|
|
|
|
|
this.validatorFactory.validator(ActionConfirmationPersist.ActionConfirmationPersistValidator.class).validateForce(persist);
|
|
|
|
|
this.actionConfirmationService.persist(persist, null);
|
|
|
|
|
|
|
|
|
|
this.validatorFactory.validator(ActionConfirmationPersist.ActionConfirmationPersistValidator.class).validateForce(persist);
|
|
|
|
|
try {
|
|
|
|
|
this.entityManager.disableTenantFilters();
|
|
|
|
|
this.actionConfirmationService.persist(persist, null);
|
|
|
|
|
} finally {
|
|
|
|
|
this.entityManager.reloadTenantFilters();
|
|
|
|
|
}
|
|
|
|
|
return persist.getToken();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -614,9 +617,14 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void confirmMergeAccount(String token) throws IOException, InvalidApplicationException {
|
|
|
|
|
ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.MergeAccount).isActive(IsActive.Active).first();
|
|
|
|
|
ActionConfirmationEntity action;
|
|
|
|
|
try {
|
|
|
|
|
this.entityManager.disableTenantFilters();
|
|
|
|
|
action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.MergeAccount).isActive(IsActive.Active).first();
|
|
|
|
|
} finally {
|
|
|
|
|
this.entityManager.reloadTenantFilters();
|
|
|
|
|
}
|
|
|
|
|
if (action == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{token, ActionConfirmationEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
|
|
|
|
|
|
this.checkActionState(action);
|
|
|
|
|
|
|
|
|
|
MergeAccountConfirmationEntity mergeAccountConfirmationEntity = this.xmlHandlingService.fromXmlSafe(MergeAccountConfirmationEntity.class, action.getData());
|
|
|
|
@ -637,11 +645,17 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
this.mergeNewUserToOld(newUser, userToBeMerge);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
action.setUpdatedAt(Instant.now());
|
|
|
|
|
action.setStatus(ActionConfirmationStatus.Accepted);
|
|
|
|
|
this.entityManager.merge(action);
|
|
|
|
|
|
|
|
|
|
this.entityManager.flush();
|
|
|
|
|
try {
|
|
|
|
|
this.entityManager.disableTenantFilters();
|
|
|
|
|
action.setUpdatedAt(Instant.now());
|
|
|
|
|
action.setStatus(ActionConfirmationStatus.Accepted);
|
|
|
|
|
this.entityManager.merge(action);
|
|
|
|
|
|
|
|
|
|
this.entityManager.flush();
|
|
|
|
|
} finally {
|
|
|
|
|
this.entityManager.reloadTenantFilters();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.userTouchedIntegrationEventHandler.handle(newUser.getId());
|
|
|
|
|
this.userRemovalIntegrationEventHandler.handle(userToBeMerge.getId());
|
|
|
|
@ -805,9 +819,15 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void confirmRemoveCredential(String token) throws InvalidApplicationException {
|
|
|
|
|
ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.RemoveCredential).isActive(IsActive.Active).first();
|
|
|
|
|
ActionConfirmationEntity action;
|
|
|
|
|
try {
|
|
|
|
|
this.entityManager.disableTenantFilters();
|
|
|
|
|
action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.RemoveCredential).isActive(IsActive.Active).first();
|
|
|
|
|
} finally {
|
|
|
|
|
this.entityManager.reloadTenantFilters();
|
|
|
|
|
}
|
|
|
|
|
if (action == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{token, ActionConfirmationEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.checkActionState(action);
|
|
|
|
|
|
|
|
|
|
RemoveCredentialRequestEntity removeCredentialRequestEntity = this.xmlHandlingService.fromXmlSafe(RemoveCredentialRequestEntity.class, action.getData());
|
|
|
|
@ -828,11 +848,17 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
}
|
|
|
|
|
this.deleterFactory.deleter(UserCredentialDeleter.class).delete(List.of(userCredentialEntity));
|
|
|
|
|
|
|
|
|
|
action.setUpdatedAt(Instant.now());
|
|
|
|
|
action.setStatus(ActionConfirmationStatus.Accepted);
|
|
|
|
|
this.entityManager.merge(action);
|
|
|
|
|
|
|
|
|
|
this.entityManager.flush();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
this.entityManager.disableTenantFilters();
|
|
|
|
|
action.setUpdatedAt(Instant.now());
|
|
|
|
|
action.setStatus(ActionConfirmationStatus.Accepted);
|
|
|
|
|
this.entityManager.merge(action);
|
|
|
|
|
this.entityManager.flush();
|
|
|
|
|
} finally {
|
|
|
|
|
this.entityManager.reloadTenantFilters();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.userTouchedIntegrationEventHandler.handle(userCredentialEntity.getUserId());
|
|
|
|
|
|
|
|
|
@ -854,10 +880,16 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UserEntity getUserEntityFromToken(String token) throws MyForbiddenException, MyNotFoundException {
|
|
|
|
|
ActionConfirmationEntity action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.MergeAccount).isActive(IsActive.Active).first();
|
|
|
|
|
private UserEntity getUserEntityFromToken(String token) throws MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
|
|
|
|
ActionConfirmationEntity action;
|
|
|
|
|
try {
|
|
|
|
|
this.entityManager.disableTenantFilters();
|
|
|
|
|
action = this.queryFactory.query(ActionConfirmationQuery.class).tokens(token).types(ActionConfirmationType.MergeAccount).isActive(IsActive.Active).first();
|
|
|
|
|
} finally {
|
|
|
|
|
this.entityManager.reloadTenantFilters();
|
|
|
|
|
}
|
|
|
|
|
if (action == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{token, ActionConfirmationEntity.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.checkActionState(action);
|
|
|
|
|
|
|
|
|
|
MergeAccountConfirmationEntity mergeAccountConfirmationEntity = this.xmlHandlingService.fromXmlSafe(MergeAccountConfirmationEntity.class, action.getData());
|
|
|
|
|