diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a085d7..4ac12ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improve add/remove admin emails - Added Valid From to Invitation Flow +### Fixed +- Correct calculation of membership expiration for enrollment request of an already member + ## [0.21.1] ### Fixed diff --git a/src/main/java/org/rciam/plugins/groups/jpa/repositories/UserGroupMembershipExtensionRepository.java b/src/main/java/org/rciam/plugins/groups/jpa/repositories/UserGroupMembershipExtensionRepository.java index 28b08e5..e1e4548 100644 --- a/src/main/java/org/rciam/plugins/groups/jpa/repositories/UserGroupMembershipExtensionRepository.java +++ b/src/main/java/org/rciam/plugins/groups/jpa/repositories/UserGroupMembershipExtensionRepository.java @@ -430,9 +430,11 @@ public void createOrUpdate(GroupEnrollmentRequestEntity enrollmentEntity, Keyclo if (isNotMember) { entity.setValidFrom(configuration.getValidFrom() == null || !configuration.getValidFrom().isAfter(LocalDate.now()) ? LocalDate.now() : configuration.getValidFrom()); } - if (configuration.getMembershipExpirationDays() != null) { + if (configuration.getMembershipExpirationDays() != null && entity.getValidFrom().isAfter(LocalDate.now())) { entity.setMembershipExpiresAt(entity.getValidFrom().plusDays(configuration.getMembershipExpirationDays())); - } else { + } else if (configuration.getMembershipExpirationDays() != null) { + entity.setMembershipExpiresAt(LocalDate.now().plusDays(configuration.getMembershipExpirationDays())); + }else { entity.setMembershipExpiresAt(null); } entity.setGroup(configuration.getGroup());