diff --git a/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java b/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java index 15eed455e..37ac7b759 100644 --- a/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java +++ b/backend/core/src/main/java/org/opencdmp/commons/enums/ActionConfirmationType.java @@ -20,7 +20,7 @@ public enum ActionConfirmationType implements DatabaseEnum { @Override @JsonValue public Short getValue() { - return value; + return this.value; } private static final Map map = EnumUtils.getEnumValueMap(ActionConfirmationType.class); diff --git a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java index a8c503914..d34503e54 100644 --- a/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/user/UserServiceImpl.java @@ -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 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()); diff --git a/notification-service/notification-web/src/main/resources/config/notification-devel.yml b/notification-service/notification-web/src/main/resources/config/notification-devel.yml index d429c4180..75a6ed388 100644 --- a/notification-service/notification-web/src/main/resources/config/notification-devel.yml +++ b/notification-service/notification-web/src/main/resources/config/notification-devel.yml @@ -208,8 +208,6 @@ notification: optional: - key: "{expiration_time}" value: --- - - key: "{tenant-url-path}" - value: formatting: '[{userName}]': null '[{installation-url}]': null @@ -235,8 +233,6 @@ notification: value: email - key: "{expiration_time}" value: -- - - key: "{tenant-url-path}" - value: formatting: '[{email}]': null '[{tenant-url-path}]': null diff --git a/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/email/body.en.html b/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/email/body.en.html index bc83e6bff..90b7607e6 100644 --- a/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/email/body.en.html +++ b/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/email/body.en.html @@ -271,7 +271,7 @@ - +
Confirm Merge Request Confirm Merge Request
diff --git a/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/inapp/body.en.html b/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/inapp/body.en.html index 262b32651..fd2e7a0c7 100644 --- a/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/inapp/body.en.html +++ b/notification-service/notification-web/src/main/resources/notification_templates/mergeacountconfirmation/inapp/body.en.html @@ -9,6 +9,6 @@

User {userName} have sent you a merge Request.

Please confirm that you want to merge your {installation-url} account with that account.
The link will expire in {expiration_time}.

- Confirm Merge Request + Confirm Merge Request \ No newline at end of file diff --git a/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/email/body.en.html b/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/email/body.en.html index bd992e823..059cae435 100644 --- a/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/email/body.en.html +++ b/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/email/body.en.html @@ -271,7 +271,7 @@ - +
Confirm Unlink Request Confirm Unlink Request
diff --git a/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/inapp/body.en.html b/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/inapp/body.en.html index b49ccb1ad..4a3d5dd30 100644 --- a/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/inapp/body.en.html +++ b/notification-service/notification-web/src/main/resources/notification_templates/removecredentialconfirmation/inapp/body.en.html @@ -9,6 +9,6 @@

You have made a request to unlink your email account in OpenCDMP.

Please confirm that you want to unlink your {email} account.
The link will expire in {expiration_time}.

- Confirm Unlink Request + Confirm Unlink Request \ No newline at end of file